opencv例程源代码-电脑摄像头人脸识别-facedetect.cpp

这篇博客介绍了如何在OpenCV 3.4.5版本中运行cpp样本代码facedetect.cpp,用于实现电脑摄像头的人脸识别功能。在VS2017中运行时遇到fopen错误,由于函数的安全性问题,微软提供了新的函数替代。解决此问题可以参考百度经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

源代码在opencv中的例程里面,文件路径如下:
opencv\sources\samples\cpp\facedetect.cpp。
(PS:所用OpenCV版本为3.4.5)
VS2017运行会提示错误,fopen。This function or variable may be unsafe。
是因为以前的函数安全性不够,所以微软重写了新的函数。
解决方法-百度经验

#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>

using namespace std;
using namespace cv;

static void help()
{
	cout << "\nThis program demonstrates the use of cv::CascadeClassifier class to detect objects (Face + eyes). 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=<cascade_path> 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=<image scale greater or equal to 1, try 1.3 for example>]\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 detec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值