Exporting and Displaying Analysis results

Analysis results can be exported to tables or augmented video streams. They can be displayed in external softwares, as well as in Google Collab or Jupyter notebooks.

Exporting analysis results to table formats

Analysis pipelines defined in module inaFaceAnalyzer.inaFaceAnalyzer return frame-coded results as pandas.DataFrame (see documentation). They can be exported to any table format supported by pandas (csv, excell, json, etc..)

>>> from inaFaceAnalyzer.inaFaceAnalyzer import VideoAnalyzer
>>> # create a video analyzer instance (costly, do it a single time)
>>> va = VideoAnalyzer()
>>> # perform video analysis, analysing a single image frame per second (fps=1)
>>> df = va('./media/pexels-artem-podrez-5725953.mp4', fps=1)
>>> # export pandas Dataframe result to csv
>>> df.to_csv('./myanalysis.csv')

Visualizing analysis results

Module inaFaceAnalyzer.display_utils contains functions allowing to export video analysis results to formats allowing to display incrusted face detection bounding boxes and classification estimates.

Display functions are currenly limited to the results obtained with inaFaceAnalyzer.inaFaceAnalyzer.VideoAnalyzer and inaFaceAnalyzer.inaFaceAnalyzer.VideoTracking analysis pipelines.

>>> from inaFaceAnalyzer.inaFaceAnalyzer import VideoAnalyzer
>>> from inaFaceAnalyzer.display_utils import ass_subtitle_export
>>> va = VideoAnalyzer()
>>> input_vid = './media/pexels-artem-podrez-5725953.mp4'
>>> # define analysis_fps=2 in order to process 2 image frames per second of video
>>> # analysis_fps should be used for analysis AND subtitle export
>>> analysis_fps = 2
>>> df = va(input_vid, fps=analysis_fps)
>>> # export results to ass subtitle
>>> ass_subtitle_export(vid_src, df, './mysubtitle.ass', analysis_fps=analysis_fps)
inaFaceAnalyzer.display_utils.ass_subtitle_export(vid_src, result_df, ass_dst, analysis_fps=None)[source]

Export inaFaceAnalyzer results to ASS subtitles . ASS can embed complex shapes such as annotated face bounding boxes and classification predictions.

Subtitles are a good option for sharing results, since they do not require a large amount of storage size, and do not alter original videos. Ass subtitles can be displayed in VLC, Aegisub or ELAN annotation software.

>>> # displaying mysample_FP2.ass subtitle with vlc
>>> vlc --sub-file ./mysample_FPS2.ass ./sample_vid.mp4
Parameters:
  • vid_src (str) – path to the input video.

  • result_df (str or pandas.DataFrame) – video analysis result provided as pandas.DataFrame or path to saved csv.

  • ass_dst (str) – output filepath used to save the resulting subtitle. Must have ass extension.

  • analysis_fps (numeric or None, optional) – Amount of frames per second which were analyzed (fps analysis argument) if set to None, then consider that all video frames were processed. Defaults to None.

inaFaceAnalyzer.display_utils.video_export(vid_src, result_df, vid_dst, analysis_fps=None)[source]

Export inaFaceAnalyzer results to a video with incrusted faces bounding boxes and other analysis information.

Parameters:
  • vid_src (str) – path to the input video.

  • result_df (str or pandas.DataFrame) – video analysis result provided as pandas.DataFrame or path to saved csv.

  • vid_dst (str) – output path of the resulting video. Must have MP4 extension.

  • analysis_fps (int, optional) – Amount of frames per second which were analyzed (fps analysis argument). If set to None, then consider that all video frames were processed. Defaults to None.

Playing videos in notebooks

Module inaFaceAnalyzer.notebook_utils contain simple functions allowing to display video in jupyter and google collab’s notebooks. These functions can be used only in a notebook environment