Data Structures
This section present the 3 internal data structures implemented in inaFaceAnalyzer.
inaFaceAnalyzer.rect.Rect
: a rectangle implementation usefull for manipulating face bounding boxesinaFaceAnalyzer.face_detector.Detection
: obtained from face detection systems, containing face bounding boxes together with face detection confidenceinaFaceAnalyzer.face_tracking.TrackDetection
: an extension ofDetection
used when combining face detection and tracking
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:
x1 (
float
) – lefty1 (
float
) – topx2 (
float
) – righty2 (
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:
- property h
self height
- 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:
- scale(scale_prct)[source]
scale self according to a given scale percentage
- Parameters:
scale_prct (float) –
- Return type:
- property square
returns the smallest square containing the rectangle
- transpose(xoffset, yoffset)[source]
Translation
- Parameters:
xoffset (float) – horizontal offset.
yoffset (float) – vertical offset.
- Return type:
- property w
self width
- namedtuple inaFaceAnalyzer.face_detector.Detection(bbox: Rect, detect_conf: float)[source]
Bases:
NamedTuple
Atomic element returned by face detection classes
- Fields:
bbox (
Rect
) – position of the detected face in the image in pixelsdetect_conf (
float
) – face detection confidence (0 = lowest confidence, 1 = highest confidence)
- namedtuple inaFaceAnalyzer.face_tracking.TrackDetection(bbox: Rect, face_id: int, detect_conf: float, track_conf: float)[source]
Bases:
NamedTuple
Atomic element returned by face tracking and detection classes
- Fields:
bbox (
Rect
) – bounding boxface_id (
int
) – detected face numerical identifierdetect_conf (
float
) – face detection confidencetrack_conf (
float
) – tracking confidence