# Extract faces from video files
#
# Authors: Sebastien Marcel (marcel@idiap.ch)
#          Yann Rodriguez (rodrig@idiap.ch)
#
# download a video from http://mmm.idiap.ch/publicMeetings.html
#
# for instance: Camera1 of Scripted-Meeting-TRN-01 (Cam1_T000009.880_T000508.520.avi)

#
# Step 1: exec without any arguments to get command line options
#
> ./facedetect-video
facedetect-video, Torch 3 vision 2.0, (c) IDIAP 2004

This program reads a video file and detects faces

Authors: Sebastien Marcel (marcel@idiap.ch)

#
# usage: ./Linux_DBG_FLOAT/facedetect-video [options] <input filename>
#

Arguments:
  <input filename>    -> video filename (<string>)

Video Options:
  -vitc               -> extract vitc timecode 
  -I <int>            -> number of images to process (all if -1) [-1]
  -drop <int>         -> number of images to drop [0]
  -F                  -> stop when a face is found 
  -seek <string>      -> seek video hh:mm:ss:ff []

Face detection options:
  -minsize <int>      -> minimum size [114]
  -maxsize <int>      -> maximum size [152]
  -model <string>     -> model filename [./models/mct4.cascade]
  -threshold <real>   -> threshold [0.1]
  -colorcube <string> -> colorcube filename []

Ouput Options:
  -o <string>         -> output basename [image]
  -saveall            -> save all images 
  -savedetect         -> save image when detected faces 
  -saveskin           -> save skin image 
  -jpg                -> save images as jpeg (ppm by default) 
  -crop               -> crop detected faces 
  -wcrop <int>        -> crop width [-1]
  -hcrop <int>        -> crop height [-1]
  -border <int>       -> border [0]

Other Options:
  -verbose            -> verbose 

#
# Step 2: check if the video file format is supported
#
>./aviduration -verbose -ffmpeg Cam1_T000009.880_T000508.520.avi
width = 720
height = 576
nframes = 7713
fps = 25
duration = 308
codec = [mpeg4]

./avi2avippm -verbose -ffmpeg -ppm -I 25 Cam1_T000009.880_T000508.520.avi
width = 720
height = 576
nframes = 7713
fps = 25
r024 

> ls -1 *.ppm
image000000.ppm
image000001.ppm
image000002.ppm
image000003.ppm
image000004.ppm
image000005.ppm
image000006.ppm
image000007.ppm
image000008.ppm
image000009.ppm
image000010.ppm
image000011.ppm
image000012.ppm
image000013.ppm
image000014.ppm
image000015.ppm
image000016.ppm
image000017.ppm
image000018.ppm
image000019.ppm
image000020.ppm
image000021.ppm
image000022.ppm
image000023.ppm
image000024.ppm

#
# Step 3: run the face detector
#
> ./facedetect-video Cam1_T000009.880_T000508.520.avi -verbose -vitc -I 100 -threshold 0.1 -crop -o cam1 -jpg -minsize 38 -maxsize 114 -drop 10 -seek 0:0:00:10
width = 720
height = 576
nframes = 7713
fps = 25
lenght = 00:05:08:13 (7713)
seek to = 0:0:0:10 (10)
 00:00:14:06 100%

> ls *.jpeg 
  
cam1-000000.face0.jpeg
cam1-000011.face0.jpeg
cam1-000022.face0.jpeg
cam1-000022.face1.jpeg
cam1-000033.face0.jpeg
cam1-000044.face0.jpeg
cam1-000044.face1.jpeg
cam1-000055.face0.jpeg
cam1-000055.face1.jpeg
cam1-000066.face0.jpeg
cam1-000077.face0.jpeg
cam1-000088.face0.jpeg
cam1-000088.face1.jpeg
cam1-000099.face0.jpeg

> cat cam1.log
Detecting faces in video file = Cam1_T000009.880_T000508.520.avi
width = 720
height = 576
nframes=7713
fps=25
000000 00:00:10:07 463 265 48 48 0.172477
000011 00:00:10:18 470 269 44 44 0.152276
000022 00:00:11:04 180 256 43 43 0.14839
000022 00:00:11:04 465 265 47 47 0.134521
000033 00:00:11:15 455 253 49 49 0.170341
000044 00:00:12:01 180 245 48 48 0.17795
000044 00:00:12:01 455 250 51 51 0.168221
000055 00:00:12:12 175 237 49 49 0.209235
000055 00:00:12:12 459 253 51 51 0.163783
000066 00:00:12:23 174 239 45 45 0.194127
000077 00:00:13:09 169 233 48 48 0.194076
000088 00:00:13:20 170 236 46 46 0.193001
000088 00:00:13:20 467 273 43 43 0.13966
000099 00:00:14:06 468 272 45 45 0.138891

# the log file format is upperleft x, upperleft y, width, height, confidence

