Data Structures

This section present the 3 internal data structures implemented in inaFaceAnalyzer.

The remaining data structures used to exchange data between modules are based on pandas.DataFrame, allowing easy exports to various table formats (see pandas’s documentation).

namedtuple inaFaceAnalyzer.rect.Rect(x1: float, y1: float, x2: float, y2: float)[source]

Bases: NamedTuple

This class is an internal data structure allowing to manipulate rectangle shapes

Fields
  1.  x1 (float) – left

  2.  y1 (float) – top

  3.  x2 (float) – right

  4.  y2 (float) – bottom

__contains__(point)[source]

point contained in self

Parameters

point (tuple) – (x,y)

Returns

True if point is in self, else False

Return type

bool

property area

self Surface area

property center

center (x,y) of self (x1, y1, x2, y2)

static from_dlib(x)[source]

create Rect from dlib’s rectangle instance

Parameters

x (dlib.rectangle or dlib.drectangle) –

Return type

Rect

property h

self height

intersect(r)[source]

Rectangle intersection between self and r

Parameters

r (Rect) –

Return type

Rect

iou(r)[source]

Intersection Over Union between self and r

Parameters

r (Rect) –

Return type

float

property max_dim_len

max (width, height)

mult(x, y)[source]

Multiply self coordinates by horizontal and vertical scaling factors Usefull for converting [0…1] coordinates to image frame dimensions in pixels

Parameters
  • (float (x) – horizontal scaling factor.

  • y (float) – vertical scaling factor.

Return type

Rect

scale(scale_prct)[source]

scale self according to a given scale percentage

Parameters

scale_prct (float) –

Return type

Rect

property square

returns the smallest square containing the rectangle

to_dlibFloat()[source]

Convert self to dlib.drectangle (float)

Return type

dlib.drectangle

to_dlibInt()[source]

Convert self to dlib.rectangle (int)

Return type

dlib.rectangle

to_int()[source]

Convert self coordinates (float) to the nearest int values :rtype: Rect

transpose(xoffset, yoffset)[source]

Translation

Parameters
  • xoffset (float) – horizontal offset.

  • yoffset (float) – vertical offset.

Return type

Rect

property w

self width

namedtuple inaFaceAnalyzer.face_detector.Detection(bbox: inaFaceAnalyzer.rect.Rect, detect_conf: float)[source]

Bases: NamedTuple

Atomic element returned by face detection classes

Fields
  1.  bbox (Rect) – position of the detected face in the image in pixels

  2.  detect_conf (float) – face detection confidence (0 = lowest confidence, 1 = highest confidence)

namedtuple inaFaceAnalyzer.face_tracking.TrackDetection(bbox: inaFaceAnalyzer.rect.Rect, face_id: int, detect_conf: float, track_conf: float)[source]

Bases: NamedTuple

Atomic element returned by face tracking and detection classes

Fields
  1.  bbox (Rect) – bounding box

  2.  face_id (int) – detected face numerical identifier

  3.  detect_conf (float) – face detection confidence

  4.  track_conf (float) – tracking confidence