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

Face detection from UIImage #3

Open
skyfoxa opened this issue Jul 19, 2016 · 5 comments
Open

Face detection from UIImage #3

skyfoxa opened this issue Jul 19, 2016 · 5 comments

Comments

@skyfoxa
Copy link

skyfoxa commented Jul 19, 2016

HI, great job, very helpfull project. I'm working on face detection for now, but I need detect face landmarks from an UIImage. Could you give me a hand how to switch the detection from video output? I don't have matedata and faceObject rects as you in AVCaptureVideoDataOutputSampleBufferDelegate, sou I use custom CIDetectorFaceType. But rects from my detector are very diferent from yours, so detected points arent correct. Do you have any hint what to do? Thanks

@zweigraf
Copy link
Owner

Please check in which format the rects are that you get from CIDetectorFaceType.

AVCaptureVideoDataOutputSampleBufferDelegate delivers rectangles with valid values from 0 to 1 (0 being the leftmost point of the image, 1 being the rightmost; see https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVMetadataObject_Class/index.html#//apple_ref/occ/instp/AVMetadataObject/bounds for more details).

Dlib expects the face rectangles to be in pixel coordinates, that means from 0px to e.g. 640px. That means we have to convert the rectangles (convert relative values from AVMetadataObject to absolute values by multiplying with the size of the complete image).

As far as I can see from https://developer.apple.com/library/ios/documentation/CoreImage/Reference/CIFeature_Ref/index.html#//apple_ref/occ/instp/CIFeature/bounds, the bounds are already in image pixel coordinates. That means you do not need to multiply by the image size, so you can skip the convertScaleCGRect:toDlibRectacleWithImageSize: step that is done in DlibWrapper.mm.

@virut26
Copy link

virut26 commented Jul 30, 2016

Could you please show some example code in Objective-c.

@zweigraf
Copy link
Owner

zweigraf commented Aug 1, 2016

@virut26 Please stop this. I am sure most professional iOS developer will be glad to port the Swift code to Objective-C. GitHub is not a marketplace for free work.

@vuvkar
Copy link

vuvkar commented Apr 12, 2018

Hi, This project is a great one, it helped me in the beginning of using dlib in iOS. I also want to get dlib::rectangle from iOS CIFaceFeature, as it is much faster. The thing is that, using face detection with faceFeature.bound rect the points are calculated wrong. I compared 2 dlib::rectangles, one gotten from faceFeature.rect, and the other from dlib::get_frontal_face_detector(). the second one's rect is much smaller compared to the first one. Are there any ideas how to solve this problem.

@softdev999
Copy link

This project is really great!!!, but I got the same issue when we try to do face detect from UIImage, we have same issue above. @luis, could you please help us on this? Thank you

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

5 participants