我在OpenCV中使用此代码进行面部检测。运行时,程序运行良好,并检测我的脸一秒钟后,我看到这个错误
这是我的代码:
#include <opencv2\core\core.hpp>
#include <opencv2\contrib\contrib.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\objdetect\objdetect.hpp>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int main()
{
CascadeClassifier face_cascade;
face_cascade.load("haarcascade_frontalface_alt2.xml");
VideoCapture captureDevice;
captureDevice.open(0);
Mat captureFrame;
Mat grayscaleFrame;
namedWindow("outputCapture", 1);
while (true)
{
captureDevice >> captureFrame;
cvtColor(captureFrame, grayscaleFrame, CV_BGR2GRAY);
equalizeHist(grayscaleFrame, grayscaleFrame);
std::vector<Rect> faces;
face_cascade.detectMultiScale(grayscaleFrame, faces, 1.1, 3
, CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_SCALE_IMAGE, Size(30, 30));
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(captureFrame, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8, 0);
}
imshow("outputCapture", captureFrame);
waitKey(33);
}
return 0;
}
我该怎么办?