Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are the proprties for get the coordinate to crop the images ? #35

Closed
NarasimmanSaravana1994 opened this issue Nov 5, 2019 · 2 comments

Comments

@NarasimmanSaravana1994
Copy link

NarasimmanSaravana1994 commented Nov 5, 2019

@biubug6
for the code, I find the crop coordinate but it not properly cropping,

ex:

            x = int(b[0])
            y = int(b[1])
            w = int(b[2])
            h = int(b[3])

            crop_img = img_raw[y:y+h,x:x+w]

please provide the coordinate for cropping he face

@biubug6
Copy link
Owner

biubug6 commented Nov 6, 2019

You can refer to "_crop()" in https://github.com/biubug6/Pytorch_Retinaface/blob/master/data/data_augment.py for detials.
ps: It would calculate iou between box and crop_img.

@deepconsc
Copy link

@NarasimmanSaravana1994

rectangle is added as following:

cv2_imshow(cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),2))

I'd suggest numpy-approach for cropping, as:

crop_img = raw_img[y:y+h, x:x+w]
In dets object, we have b[0],b[1],b[2],b[3], where b[1], b[3] are y, y+h, and b[0], b[2] are x,x+w

Therefore, cropping goes as:

cropped = img_raw[b[1]:b[3], b[0]:b[2]]

Works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants