opencvf+for+linux_基于OpenCV的人脸识别程序

本文档介绍了如何在Ubuntu 15.04上使用OpenCV 3.1.0进行人脸识别。通过解析示例代码facedetect.cpp,展示了如何加载级联分类器并进行人脸检测。程序包括对输入图像或摄像头视频流的处理,并使用了级联分类器和嵌套分类器。在执行过程中,如果遇到捕获帧时的超时问题,可能需要检查摄像头设置。
摘要由CSDN通过智能技术生成

1. 解析opencv自带人脸识别源码(……/opencv-3.1.0/samples/cpp/facedetect.cpp)

@ 操作系统:Ubuntu 15.04

OpenCV版本:3.1.0

#include "opencv2/objdetect.hpp"

#include "opencv2/highgui.hpp"

#include "opencv2/imgproc.hpp"

#include

using namespace std;

using namespace cv;

static void help()

{

cout << "\nThis program demonstrates the cascade recognizer. Now you can use Haar or LBP features.\n"

"This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.\n"

"It's most known use is for faces.\n"

"Usage:\n"

"./facedetect [--cascade= this is the primary trained classifier such as frontal face]\n"

"  [--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]\n"

"  [--scale=]\n"

"  [--try-flip]\n"

"  [filename|camera_index]\n\n"

"see facedetect.cmd for one call:\n"

"./facedetect --cascade=\"../../data/haarcascades/haarcascade_frontalface_alt.xml\" --nested-cascade=\"../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml\" --scale=1.3\n\n"

"During execution:\n\tHit any key to quit.\n"

"\tUsing OpenCV version " << CV_VERSION << "\n" << endl;

}

void detectAndDraw( Mat& img, CascadeClassifier& cascade,

CascadeClassifier& nestedCascade,

double scale, bool tryflip );

string cascadeName;

string nestedCascadeName;

int main( int argc, const char** argv )

{

VideoCapture capture;

Mat frame, image;

string inputName;

bool tryflip;

// CascadeClassifier是Opencv中做人脸检测的时候的一个级联分类器,现在有两种选择:一是使用老版本的CvHaarClassifierCascade函数,一是使用新版本的C

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值