Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the source code of OpenCV face recognition

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to write the source code of OpenCV face recognition". In daily operation, I believe that many people have doubts about how to write the source code of OpenCV recognition of other people's faces. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to compile the source code of OpenCV face recognition". Next, please follow the editor to study!

1. Automatic photo taking

When collecting your own image before, the program is set to press the'p 'key to take a picture and save the image, and then need to manually convert the image size to the same size as the picture in the ORL face database.

Now everything is automatic, just run to take pictures, change sizes, and save. The default setting is to take 10 photos, which is consistent with the ORL face database.

2. Python script generates at.txt

At that time, I didn't know how to use Python when I was writing a blog, so the generated at.txt was either the label for the S1 folder or 1 for S2. It's messy. Who is who needs to be remembered by himself.

The modified Python script can be a folder, but the label matches perfectly.

3. Training code

There are some changes in the code part of the training face recognition model, mainly because of the change of OpenCV.

Header files and namespaces need to be added:

# include

Using namespace cv::face

The original code for the change in the creation model is:

Ptr model = createEigenFaceRecognizer ()

Ptr model1 = createFisherFaceRecognizer ()

Ptr model2 = createLBPHFaceRecognizer ()

Now change to:

Ptr model = createEigenFaceRecognizer ()

Ptr model1 = createFisherFaceRecognizer ()

Ptr model2 = createLBPHFaceRecognizer ()

The rest hasn't changed much.

At this point, on the "OpenCV face recognition source code how to write" on the end of the study, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report