1

Hi I need help with the boundary of the eye roi since it is so to the left, to get it in the middle.A lot of examples for eyes are separated and/or in a circular shape.

img = cv2.imread('man1.png')
newImg = cv2.resize(img, (600,600))
#gray = cv2.cvtColor(newImg, cv2.COLOR_BGR2GRAY)
#gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale(newImg,
                                     scaleFactor=1.1,
                                     minNeighbors=5,
                                     #minSize=(60, 60),
                                     flags=cv2.CASCADE_SCALE_IMAGE)
for (x,y,w,h) in faces:
    cv2.rectangle(newImg, (x, y), (x + w, y + h),(0,0,0), 1)
    faceROI = newImg[y:y+h,x:x+w]
    #cv2.imwrite(str(w) + str(h) + '_faces.jpg', faceROI)
    
    #roi_gray = gray[y:y + h, x:x + w] 
    #roi_color = frame[y:y + h, x:x + w]
    
    eyes = eyeCascade.detectMultiScale(faceROI)
    smiles = mouthCascade.detectMultiScale(faceROI,scaleFactor=1.6, minNeighbors=5)
   
    for (ex,ey,ew,eh) in eyes:
        cv2.rectangle(faceROI,(x,y),(ex+w,y+eh),(0,0,0),-1)
  

    # Display the resulting frame
cv2.imshow('Image', newImg)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

last = cv2.imwrite('faces_detected.png', faceROI)
cv2.destroyAllWindows()

enter image description here

0 Answers0