Hello, everyone. I've got problem with detecting face. When I use CascadeClassifier.Detectmultiscale(gray,faces,1.1,2) I have the error in std::algorithm Access Reading Violation. I'm using OpenCv 3.4.6 and c++. It's code(P.S. It delay camera it's take picture and detect):
include "opencv2/opencv.hpp"
include "opencv2/objdetect/objdetect.hpp"
include "opencv2/imgproc/imgproc.hpp"
include <iostream>
include "windows.h"
using namespace cv; using namespace std;
int main(int argc, char** argv) {
String face_cascade_name = "C:\Opencv-3.4.6\sources\data\haarcascades\haarcascade_frontalface_default.xml"; CascadeClassifier face_cascade; RNG rng(12345); Mat image; face_cascade.load(face_cascade_name);
if (face_cascade.empty())
{
cerr << "NOP!" << endl;
}
namedWindow("Camera", WINDOW_AUTOSIZE);
int delay;
cout << "Write the delay: ";
cin >> delay;
VideoCapture png(0);
if (!png.isOpened()) // check if we succeeded
return -1;
Sleep(delay * 1000);
png >> image;
vector<Rect> faces;
Mat gray;
cvtColor(image, gray, COLOR_BGR2GRAY);
equalizeHist(gray, gray);
face_cascade.detectMultiScale(gray, faces, 1.1, 2);
imshow("Camera", image);
waitKey(0);
}
Help me as soon as it possible.
Best Regards,
TheGamerCoder.