带有OpenCV错误的视频中的人脸检测关闭程序 我在OpenCV 中使用C++的人脸检测方案
当程序确定面时 退出节目 为什么? 视频显示了问题所在: 图片: 代码:带有OpenCV错误的视频中的人脸检测关闭程序 我在OpenCV 中使用C++的人脸检测方案,c++,opencv,C++,Opencv,当程序确定面时 退出节目 为什么? 视频显示了问题所在: 图片: 代码: #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include <stdio.h> using namespace std;
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main(int argc, const char *argv[]){
if (argc != 4) {
cout << "usage: " << argv[0] << " </path/to/haar_cascade> </path/to/csv.ext> </path/to/device id>" << endl;
cout << "\t </path/to/haar_cascade> -- Path to the Haar Cascade for face detection." << endl;
cout << "\t </path/to/csv.ext> -- Path to the CSV file with the face database." << endl;
cout << "\t <device id> -- The webcam device id to grab frames from." << endl;
// exit(1);
}
CascadeClassifier face_cascade;
String fn="C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml";
face_cascade.load(fn);
VideoCapture input(0);
if(!input.isOpened()){return -1;}
namedWindow("Mezo",1);
Mat f2;
Mat frame;
while(true){
input>>frame;
waitKey(10);
cvtColor(frame, f2, CV_BGR2GRAY);
equalizeHist(f2, f2);
std::vector<Rect> faces;
face_cascade.detectMultiScale(f2, faces, 1.1, 10, CV_HAAR_SCALE_IMAGE | CV_HAAR_DO_CANNY_PRUNING,Size(150,0),Size(300,300));
//draw a rectangle for all found faces in the vector array on the original image
for(int i = 0; i < faces.size(); i++)
{
Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
Point pt2(faces[i].x, faces[i].y);
rectangle(frame, pt1, pt2, cvScalar(0, 255, 0, 0), 2, 8, 0);
}
imshow("Mezo",frame);
waitKey(3);
char c=waitKey(3);
if(c==27){break;}
}
return 0;
}
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间cv;
int main(int argc,const char*argv[]{
如果(argc!=4){
请将错误消息粘贴到此处。您的视频无效。TestOpenCv.exe已触发断点。pUserData 0x00000081415330c0 const void*断点并不意味着您已崩溃…(但如果您没有设置它,您可能已经成功了)