Opencv learning notes () -- use opencv to recognize human faces and gender recognition contrib

Source: Internet
Author: User
The story of face recognition can't be told. Let's leave the investigation to everyone. Here we are talking about face recognition with opencv.

Because it is real face recognition and not funny entertainment, the database must be powerful. We recommend a website http://www.face-rec.org/databases /. Here is an overview of the most comprehensive face database. I hope you can find the desired face Library (PS: I need a 3D face library, but I don't know which man knows how to get it free, or if you are willing to share it with me, it is even better. Thank you first ). Here we will briefly introduce two libraries: orl and Yale. orl are a lightweight library. Yale is more complicated, but not free.

Data preparation: we need to read images and corresponding labels in our program. CSV files are used here, which is a simple data interaction format, this format is supported in our most commonly used Excel files. In this format, each piece of information occupies one row. The information format is file name, label, for example, C:/orl/image.jpg; 0. You can train any database by creating a CSV file and corresponding images. Of course, this CSV file does not have to be manually created. You can also use a Python script to generate the CSV file you need, the corresponding script is \ modules \ contrib \ doc \ FaceRec \ SRC \ create_csv.py. Alas, who made me unfamiliar with this script can only be lazy, directly call \ modules \ contrib \ doc \ FaceRec \ etc \ at.txt or \ samples \ CPP \ facerec_at_t.txt. This TXT corresponds to the ORL database, and the path is changed according to it.

As for the specific implementation of face recognition, I have discussed how to implement the facerecognizer face recognition class contrib in blogopencv Study Notes. \ Modules \ contrib \ doc \ FaceRec \ SRC many good examples, I will not upload the code here.

Finally, let's talk about face calibration. I am not very familiar with python. I just want to give you a script file, \ modules \ contrib \ doc \ FaceRec \ SRC \ crop_face.py, you can use this script to create the desired face image size.

Gender Recognition and video recognition are introduced in the corresponding demo. I will not elaborate on it here, because gender recognition only includes two types of training sample tags: male and female. It should be noted that eigenface is based on PCA and is an unsupervised model that is not suitable for gender recognition tasks. The demo here uses fisherface. For video face recognition, you simply add a videocapture and a cascadeclassifier for face detection.

You can use the SAVE and load functions to save and call the trained model. This is easy to understand.

Finally, let's talk about the Function applycolormap of the pseudo-color graph. The colormap parameter is used to select the style of the pseudo-color graph. Because the human eye is more sensitive to colors than brightness, it is better to use a pseudo-color image. This is why medical image processing is used in a lot of ways. Previously, B-ultrasound is now used in color Doppler ultrasound, and the price is much more expensive. It is actually a pseudo-color processing. The hospital is really black !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.