Good day Everyone, hope you are all doing well. I am finding it difficult to get the x,y,h,w using dlib as faces = detector(gray) in python. here is the code below. Thank you in advance.
#load the detector
detector = dlib.get_frontal_face_detector()
#load the predictor
predictor = dlib.shape_predictor('shape_predictor/shape_predictor_68_face_landmarks.dat')
while True:
frame = webcam.read()
frame = imutils.resize(frame, width=450)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = detector(gray)
for face in faces:
#face landmarks
landmarks = predictor(gray, face)
x, y = face.left(), face.top()
x1, y1 = face.right(), face.bottom()
frame_img = frame[x,y,x1,y1]
print(frame_img)
I think your error is in this expression: frame[x,y,x1,y1]. Try to replace it with this:
frame_img = frame[y:y1,x:x1]