1 | initial version |
if you want to restrict the face recognition to that rectangle, you canuse a simple ROI:
roi = gray[300,600 : 400:800] # ymin,ymax, xmin,xmax !
faces = face_cascade.detectMultiScale(
roi, scaleFactor=1.1,
minNeighbors=5,
minSize=(200, 200),
flags=cv2.CASCADE_SCALE_IMAGE)
but since you get rectangles in the ROI coord system you have to add the top-left corner to the rectangles found:
for (x, y, w, h) in faces:
cv2.rectangle(output, (x+400, y+300), (x+400 + w, y+300 + h), (255, 0, 0), 3)
besides that, a minSize of (200,200) is probably too large
2 | No.2 Revision |
if you want to restrict the face recognition to that rectangle, you canuse a simple ROI:
roi = gray[300,600 : gray[300:600 , 400:800] # ymin,ymax, xmin,xmax !
faces = face_cascade.detectMultiScale(
roi, scaleFactor=1.1,
minNeighbors=5,
minSize=(200, 200),
flags=cv2.CASCADE_SCALE_IMAGE)
but since you get rectangles in the ROI coord system now, you have to add the top-left corner to the rectangles found:found for drawing in the "large" image:
for (x, y, w, h) in faces:
cv2.rectangle(output, (x+400, y+300), (x+400 + w, y+300 + h), (255, 0, 0), 3)
besides that, a minSize of (200,200) is probably too large