How can I do facial recognition on the iPhone. Could someone provide me with references/articles to point me in the right direction please? I have done research and realised that I need to do face detection first to extract the image and then do facial recognition by comparing it with other images within a database.
I have realised that I have do the face detection by using OpenCV or by utilising iOS 5.0 and upwards to detect the face. I am unsure on the facial recognition (I plan on storing images on a remote database and then doing the comparison against the remote database).
On iPhone 12 models and iPhone 13 models with iOS 15.4 or later, you can use Face ID to unlock your phone while you wear a face mask (or other covering that blocks your mouth and nose).
Apple says the model of your face never leaves your iPhone X. It does not transmit it over any network or store it in the cloud. Like your digital Touch ID fingerprint, your Face ID data is stored specifically in something called the iPhone's secure enclave.
Face detection
I would use the Haarcascades available in open CV to perform quick and accurate face detection.
http://opencv.willowgarage.com/wiki/FaceDetection
Face recognition
I would use a method such as Principal Component Analysis (PCA) a.k.a eigenfaces.
http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html
That link shows a tutorial on how to get that working with OpenCV - I think this is written for C but i'm sure you can get the basic jist of it.
You could also look at implementing it yourself if you feel brave (it's not too bad)...
http://www.face-rec.org/algorithms/PCA/jcn.pdf
http://blog.zabarauskas.com/eigenfaces-tutorial/
Database
I actually did something similar to you albeit on a PC not an iPhone but its still the same concept. I stored all my images in the database as Blob data types then loaded them into my program when necessary.
Edit
The database is a particularly tricky part of the system as this is where the biggest bottleneck is. In my application, I would go through the following steps...
Fortunately for me, my database server was located on a LAN therefore speed wasn't a problem, however I can see why you have an issue due to the fact that on a mobile device you have a limited data connection (speed/bandwidth). You can compress the images however this may lead to a worse recognition rate, due to image quality reduction and also you will have to decode on the device. There is also the issue of how to expose the remote database to the application, however I do believe this is possible using PHP and JSON (and other technologies, see below).
Retrieving data from a remote database
Maybe you could do an initial synchronize with the database so that the images are cached on the phone? One way or another I think you are probably going to have to have the images on the phone at some point regardless.
Figuring out the best way to store the recognition data/images in the database was one of the biggest challenges I faced so I would be interested to hear if you find a good method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With