When I only detect the face the camera zoom on the face and follows it. But when I want to detect & zoom/follow the mouth it doesn’t.
Mouth detection only work when the face is detected first so I can’t just detect only the mouth as I could detect the face.
So this works:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
face = face_cascade.detectMultiScale(gray, scaleFactor=SCALE_FACTOR, minNeighbors=MIN_NEIGHBORS, minSize=MINSIZE, )
boxes = np.array(face)
But this doesn’t:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
face = face_cascade.detectMultiScale(gray, 1.3, 15)
for (x, y, w, h) in face:
roi_gray = gray[y:y + w, x:x + w]
mouth = mouth_cascade.detectMultiScale(roi_gray, scaleFactor=SCALE_FACTOR, minNeighbors=MIN_NEIGHBORS, minSize=MINSIZE,)
boxes = np.array(mouth)
What is the problem? How do I make this work?? How will I be able to detect the mouth and zoom/follow it? Any help or tips are welcome!
Main.py(full code):
https://raw.githubusercontent.com/kailau02/Dolly-Zoom/main/main.py
Frame.py:
https://raw.githubusercontent.com/kailau02/Dolly-Zoom/main/Frame.py