OpenCV4.5.1-step-by-step
从零开始学习OpenCV。
前置知识
- C++
- QT基础开发
开发环境
- Win10
- Qt5.13.2
- MinGW,g++ 8.1.0
- OpenCV4.5.1
目前我机器上 OpenCV 路劲为 D:\opencv4.5.1\opencv-build,代码中需要根据各位实际的 OpenCV 路径修改。
Github地址
GitHub地址为 https://github.com/ZHOUYI-UM/OpenCV4.5.1-step-by-step,欢迎各位大佬打星支持。
已经完成功能
- 人脸检测
- 人脸数据采集
- 脸训练
- 人脸识别
项目步骤
Step 1: Compile OpenCV4.5.1 using MinGW in Win10
For more detail, please refer to this URL[Win10 环境下搭建 Qt5.13.2 + OpenCV4.5.1 + MinGW 开发环境] (https://blog.csdn.net/justidle/article/details/121488711)。
Step 2: Project 1, First Qt project using OpenCV to read a picture
In this project, we will open a picture and show this picture in QMainWindow. Using QtCreator 4.10.1 to generate a “Qt Widgets Application”, use the default selection, But in “Kit Selection”, please use “MinGW 64-bit” not use “MSVC2017 64bit”.
Step 3: Project 2, Using OpenCV to face and eyes detection
In this project, we will use opencv to face and eyes detection. Using haarcascade_frontalface_alt.xml to do face detection. Using haarcascade_eye_tree_eyeglasses.xml to do eyes detection. This to files are provided by OpenCV, you can get it in the direction “sources/data/haarcascades”.
Step 4: Project 3, Using OpenCV to open a camera
In this project, get vedio from camera.
Step 5: Project 4, face detection from vedio
In this project, using a 100ms timer to detect face from vedio.
Step 6: Project 5, collect face data from vedio
In this project, we detect a face in vedio, and save this pic every 500ms.
Step 7: Project 6, Train the image
In this project, we will use python to train the face image. Because python is simplier than C++.
Step 8: Project 7, Generate face data in C++
In this project, we will use the at.txt, which is generated in project 6, to make a face data. We will open a face image, and push “Face data” button, We will generate EigenFaceRecognizer, FisherFaceRecognizer and LBPHFaceRecognizer from at.txt. Then press load image to load a 92*112 gray image to recognize the face.
Step 9: Project 8, Real time face recognization
In this project, we will use the face data, which is generated in poject 7, to make a face recognization from a camera. It seems that the correction using FisherFaceRecognizer is a little low.
问题
目前使用 OpenCV 最基本的人脸识别,即 EigenFaceRecognizer, FisherFaceRecognizer 和 LBPHFaceRecognizer,简单测试后,发现人脸识别的准确率没有资料中说明那么高。
可能问题是自己对 OpenCV 了解还不够,还需要进一步阅读文档。
下一步
使用 OpenCV 中的 DNN 来识别人脸。