ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.24k stars 13.48k forks source link

No faces found #553

Open yigitbacakoglu opened 6 years ago

yigitbacakoglu commented 6 years ago

Description

The picture was taken with iphone8, Library says 'no face found' on this image.

Dimensions: 2320 × 3088px yigit3

But when I capture a screenshot on mac, this works well. Dimensions: 908x1218px

yigit

What I Did

face_recognition ./known/ ./unknown/group.jpg
WARNING: No faces found in ./known/yigit3.jpg. Ignoring file.

Is it possible to consider ExifTags and rotate the picture if required in the library?

ageitgey commented 6 years ago

You have to implement EXIF rotation yourself. If you Google, there are some python examples on stack overflow that work fine. I'd like to create a simple EXIF rotation python library sometime and add that feature here, but I haven't had time yet.

DanielReyesDev commented 6 years ago

@yigitbacakoglu Hey I'm developing an iOS App and a Backend server that use Django and face_recognition. So yesterday I realized about this problem with iOS cameras in general and I came with a solution about processing the Image in my iOS App before send it to server. More info here: https://stackoverflow.com/questions/10600613/ios-image-orientation-has-strange-behavior. So yes, it's an issue about iOS Cameras and you have to pre-process the image before pass it to face_recognition, but that's not an issue of face_recognition itself. In swift I applied this method over the UIImage before send it to my backend and now It works as expected.

extension UIImage {
    func correctlyOrientedImage() -> UIImage {
        if self.imageOrientation == .up {
            return self
        }

        UIGraphicsBeginImageContextWithOptions(size, false, scale)
        draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
        let normalizedImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        return normalizedImage ?? self
    }
}
rom1504 commented 6 years ago

I just had this problem too. I took a few images from my google photos without thinking about this because google photos (and a lot of image displaying tools) auto rotate the images based on the exif, so you don't see the rotation. I understand it takes a bit of time to add this to the library, but could you just add a notice in the README for now ? So people don't get confused about getting poor results because of this problem.

Thank you for creating that really easy to use lib !

ageitgey commented 6 years ago

@rom1504 Thanks, that's a good idea. I'll do that.

ageitgey commented 6 years ago

I added it here: https://github.com/ageitgey/face_recognition/wiki/Common-Errors

rom1504 commented 6 years ago

for information, here is a way to rotate your images in python before using face_recognition https://github.com/hooram/ownphotos/blob/29e4fa855363e00fb2168cfa706ef870e23013e0/api/models.py#L254

YubinXie commented 5 years ago

I also notice that the package is bad at detecting rotated faces, while can be very common in real life. Is this because no rotation augmentation added during training?