OpenCV人脸识别三(根据训练的模型进行人脸识别)

梦里梦外; 2022-05-23 08:29 297阅读 0赞

OpenCV版本3.4.1

人脸识别算法采用:LBPHFaceRecognizer

.pro文件代码

  1. QT += core
  2. QT -= gui
  3. CONFIG += c++11
  4. TARGET = opencvTest
  5. CONFIG += console
  6. CONFIG -= app_bundle
  7. TEMPLATE = app
  8. SOURCES += main.cpp \
  9. fisherdemo.cpp \
  10. lbphdemo.cpp \
  11. lbphdemo2.cpp \
  12. lbphdemo3.cpp
  13. # The following define makes your compiler emit warnings if you use
  14. # any feature of Qt which as been marked deprecated (the exact warnings
  15. # depend on your compiler). Please consult the documentation of the
  16. # deprecated API in order to know how to port your code away from it.
  17. DEFINES += QT_DEPRECATED_WARNINGS
  18. # You can also make your code fail to compile if you use deprecated APIs.
  19. # In order to do so, uncomment the following line.
  20. # You can also select to disable deprecated APIs only up to a certain version of Qt.
  21. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
  22. INCLUDEPATH += G:/OpenCV/opencv/sources-build/install/include/opencv \
  23. G:/OpenCV/opencv/sources-build/install/include/opencv2 \
  24. G:/OpenCV/opencv/sources-build/install/include
  25. LIBS +=-LG:/OpenCV/opencv/sources-build/install/x86/mingw/lib/ \
  26. -llibopencv_core341 \
  27. -llibopencv_highgui341 \
  28. -llibopencv_imgcodecs341 \
  29. -llibopencv_imgproc341 \
  30. -llibopencv_face341 \
  31. -llibopencv_features2d341 \
  32. -llibopencv_calib3d341

main.cpp代码

  1. #include <QCoreApplication>
  2. #include <opencv2/core/core.hpp>
  3. #include <opencv2/highgui/highgui.hpp>
  4. #include <opencv2/imgproc/imgproc.hpp>
  5. #include <opencv2/imgcodecs/imgcodecs.hpp>
  6. #include <opencv2/face.hpp>
  7. #include <iostream>
  8. #include <string>
  9. using namespace cv;
  10. using namespace face;
  11. using namespace std;
  12. /**LBPHFaceRecognizer根据训练模型预测结果
  13. * @brief main
  14. * @param argc
  15. * @param argv
  16. * @return
  17. */
  18. int main(int argc,char *argv[])
  19. {
  20. QCoreApplication a(argc,argv);
  21. Mat src_5=imread("G:/opencvImage/att_faces/s3/1.pgm",CV_LOAD_IMAGE_GRAYSCALE);
  22. Ptr<FaceRecognizer> model=LBPHFaceRecognizer::create();
  23. model->read("G:/opencvImage/lbph_face.xml");
  24. int faceResult=model->predict(src_5);
  25. cout << faceResult << endl;
  26. return a.exec();
  27. }

发表评论

表情:
评论列表 (有 0 条评论,297人围观)

还没有评论,来说两句吧...

相关阅读

    相关 opencv人脸识别

    我的劳动成果。 1.成功安装了opencv ,可是它还要编译。我放弃。 2.成功训练自己的人脸分类器。(虽然数据是别人的,算法也是系统写好的,图形库也是别人调好的)虽然识别

    相关 opencv人脸识别

    opencv人脸识别: 首先我们来简单的讲一下人脸识别流程:这里采用的是vs2017+opencv3.3扩展库 1、进行人脸检测 2、识别器训练与分类 3、人脸检测