一、环境介绍
ubuntu版本: VM虚拟机运行ubuntu18.04 64位
OpenCV版本: 3.4.9
QT版本: 5.12
OpenCV在ubuntu下的编译方法:https://blog.csdn.net/xiaolong1126626497/article/details/105278882
二、建立QT工程加入OpenCV依赖库
下面编写例子很简单,使用OpenCV自带的分类器,检测一张图中的人脸,并圈出来。
opencv源码自带的人脸检测分类器目录:opencv-3.4.9/data/haarcascades_cuda/haarcascade_frontalface_alt2.xml
xxx.pro工程文件代码:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
#