I am using a face detection library(retina-face) to detect face on the following image
The library being used is retina-face which gives bounding box coordinates in the format (x1,y1,x2,y2).
The Bounding box for the face is as follows
face_area=[242, 92, 269, 129]
Now,when I run the following part of the code,I am able to draw the bounding box on the image to represent the face
img=cv2.imread('model_2_0.jpg') img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB) cv2.rectangle(img,(face_area,face_area),(face_area,face_area),(255,0,0),1)
The result of this is as follows
But when I use slicing to just obtain the face part of the image either I run into zero-sized array error or I get an incorrect result.
I am trying to crop as follows
The incorrect crop is shown below
Any idea what I am doing wrong here,and is there a better way to crop rather than using slicing