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.ABCThis 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
face_detector (instance of
inaFaceAnalyzer.face_detector.FaceDetectoror None) – if None, LibFaceDetection is used by defaultface_classifier (instance of
inaFaceAnalyzer.face_classifier.FaceClassifieror None) – if None, Resnet50FairFaceGRA is used by default (gender & age)verbose (boolean) – If True, will display several usefull intermediate images and results
- __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.FaceAnalyzerImageAnalyzer 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.FaceAnalyzerVideo 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.FaceAnalyzerFace 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.FaceAnalyzerVideo 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