Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As sturkmen said, it's quite easy. Capture the images in a loop using the VideoCapture module, then detect the faces with a Haar cascade classifier, which will give the face rectangle. Then wait till the rectangle gets in the desired area of the image. Something like:

if((face.w*face*h>min_surface)&&(face.x>target.x0)&&(face.y>target.y0)&&(face.x+face.w<target.x1)&&(face.y+face.h>target.y1) { imwrite(image,"goodcapture.jpg"); break; }

Some docs: video capture: http://docs.opencv.org/3.1.0/d8/dfe/classcv_1_1VideoCapture.html#gsc.tab=0 face detection: http://docs.opencv.org/master/d7/d8b/tutorial_py_face_detection.html#gsc.tab=0