Media Analyzer Classes

inaFaceAnalyzer module implements media analyzer classes allowing to process video or image streams.

Analysis classes inherits from abstract class FaceAnalyzer. Custom face detection, face classifier, eye detection and image preprocessing strategies can be provided in the constructor.

>>> from inaFaceAnalyzer.inaFaceAnalyzer import VideoAnalyzer
>>> # a video analyzer instance with default parameters
>>> va = VideoAnalyzer()

Analysis classes are designed as *functions objects* or *functors* : instances of these objects can be used as functions, executing the code implemented in __call__ methods. __call__ method first argument is the path to the media to analyze. It returns a pandas DataFrame.

>>> df = va(sample_vid)

Abstract Media Analyzer Class

class inaFaceAnalyzer.inaFaceAnalyzer.FaceAnalyzer(face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Bases: abc.ABC

This is an abstract class containg the pipeline used to process images, videos, with/without tracking * image/video decoding * face detection * face tracking (optional) * eye detection * face preprocessing * face classification

abstract __call__(src)[source]

Method to be implemented by each analyzer

Parameters

src (str or list) – path to the video/image to be analyzed May also be a list of images

Return type

Results stored in a pandas DataFrame

__init__(face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Constructor

Parameters
__weakref__

list of weak references to the object (if defined)

ImageAnalyzer

class inaFaceAnalyzer.inaFaceAnalyzer.ImageAnalyzer(face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Bases: inaFaceAnalyzer.inaFaceAnalyzer.FaceAnalyzer

ImageAnalyzer instances allow to detect and classify faces from images

__call__(img_paths)[source]
Parameters

img_paths (str or list) – path or list of paths to image file(s) to analyze

Returns

  • pandas Dataframe with column ‘frame’ containing the path to the source

  • image. Remaining columns depend on processing options selected and

  • contain bounding box, and face classification information

class inaFaceAnalyzer.inaFaceAnalyzer.VideoAnalyzer(face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Bases: inaFaceAnalyzer.inaFaceAnalyzer.FaceAnalyzer

Video Analyzer allows to detect and classify faces in video streams

class inaFaceAnalyzer.inaFaceAnalyzer.VideoKeyframes(face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Bases: inaFaceAnalyzer.inaFaceAnalyzer.FaceAnalyzer

Face detection and analysis from video limited to video key frames https://en.wikipedia.org/wiki/Key_frame It allows to provide a video analysis summary in fast processing time, but with non uniform frame sampling rate

class inaFaceAnalyzer.inaFaceAnalyzer.VideoTracking(detection_period, face_detector=None, face_classifier=None, batch_len=32, verbose=False)[source]

Bases: inaFaceAnalyzer.inaFaceAnalyzer.FaceAnalyzer

Video processing pipeline including face detection, tracking and classification Tracking is usually less costly than face detection (computation bottleneck) and allows to save computation time Classification decision functions and predictions are averaged for each tracked faces, allowing to obtain more robust analysis estimates