Face detection, by itself, e.g.,
will return a list of rectangles for all features in the frame that the
detector considers faces. There could be many of them, and there could
be many false positives.
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt2.xml')
face_cascade.detectMultiScale(gray, 1.1, 5)
In this assignment, implement a face object that exhibits
frame coherence. In other words, each face is labeled, e.g.,
face_0
, face_1
, and so on, and your detector
tracks where the face goes over a number of frames. If the given face
disappears from view, the detector can fade (out of existence) over a given
number of frames.
For each detected and tracked face, display in the output identified eyes, nose, and mouth within each face.
Face
object,
which contains the eye, nose, and mouth AOIs. Then, whenever
the face needs to be rendered (drawn), this object would draw
all the required rectangles.
self.leyeCascadeName = './haarcascades/haarcascade_lefteye_2splits.xml'
self.reyeCascadeName = './haarcascades/haarcascade_righteye_2splits.xml'
if cv2.__version__ == '4.0.0' or cv2.__version__ == '4.2.0':
self.noseCascadeName = './haarcascades/haarcascade_mcs_nose.xml'
elif cv2.__version__ == '3.4.1':
self.noseCascadeName = './haarcascades/Nariz.xml'
if cv2.__version__ == '4.0.0' or cv2.__version__ == '4.2.0':
self.mouthCascadeName = './haarcascades/haarcascade_mcs_mouth.xml'
elif cv2.__version__ == '3.4.1':
self.mouthCascadeName = './haarcascades/Mouth.xml'
You can test various other Haar cascade filters here:
Haar Cascades
.mp4
video could be made, although that
may need to be encoded post-facto by ffmpeg as OpenCV might only output
raw video.
An example video with three faces is given here: pl3_exports-640x360.mp4
tar.gz
archive of your asg##/ directory, including:
README
file containing
Makefile
handin
notes