Hi guys.. I need your help... cant finish my project because of this error: c0000374. After starting the program it fails and crashes. I use opencv 3.1 with VS 2010. Programm basically have to show a video window from computer webcam.
I run this code in button click eventhandler from my MFC dialog based project:
void CsdkDemoDlg::OnBnClickedButtonRecognizeFace() { cout << "start recognizing..." << endl;
//load pre-trained data sets
Ptr<cv::face::FaceRecognizer> model = cv::face::createFisherFaceRecognizer(num_compFisher,thresholdFisher);
model->load("C:\\Users\\Alexey\\Documents\\Visual Studio 2012\\Projects\\RaptorBOT_PC_Control\\С++\\RaptorBOT_PC_Control\\OpenCV3.1\\IMG_DB\\YML\\fisherface.yml");
Mat testSample = imread("C:\\Users\\Alexey\\Documents\\Visual Studio 2012\\Projects\\RaptorBOT_PC_Control\\С++\\RaptorBOT_PC_Control\\OpenCV3.1\\IMG_DB\\DB_Bilityuk_Alexey\\Snapshot_20160106.JPG");
int img_width = testSample.cols;
int img_height = testSample.rows;
string classifier = "C:\\Program Files\\opencv\\build_\\install\\etc\\haarcascades\\haarcascade_frontalface_default.xml";
CascadeClassifier face_cascade;
string window = "Capture - face";
if (!face_cascade.load(classifier)){
cout << " Error loading file" << endl;
}
VideoCapture cap(1);
if (!cap.isOpened())
{
cout << "exit" << endl;
}
//double fps = cap.get(CV_CAP_PROP_FPS);
//cout << " Frames per seconds " << fps << endl;
//namedWindow(window, 1);
int count = 0;
while(true)
{
vector<Rect> faces;
Mat frame;
Mat graySacleFrame;
Mat original;
cap >> frame;
//cap.read(frame);
count = count + 1;//count frames;
if (!frame.empty()){
//clone from original frame
original = frame.clone();
//convert image to gray scale and equalize
cvtColor(original, graySacleFrame, CV_BGR2GRAY);
//equalizeHist(graySacleFrame, graySacleFrame);
//detect face in gray image
face_cascade.detectMultiScale(graySacleFrame, faces, 1.1, 3, 0, cv::Size(80, 80));
//face_cascade.detectMultiScale(graySacleFrame, faces);
//number of faces detected
cout << faces.size() << " faces detected" << endl;
std::string frameset = SSTR(count);
std::string faceset = SSTR(faces.size());
int width = 0, height = 0;
//region of interest
//cv::Rect roi;
//person name
string Pname = "";
for (int i = 0; i < faces.size(); i++)
{
//region of interest
Rect face_i = faces[i];
//crop the roi from grya image
Mat face = graySacleFrame(face_i);
//resizing the cropped image to suit to database image sizes
Mat face_resized;
cv::resize(face, face_resized, Size(img_width, img_height), 1.0, 1.0, INTER_CUBIC);
//recognizing what faces detected
int label = -1; double confidence = 0;
model->predict(face_resized, label, confidence);
cout << " confidencde " << confidence << endl;
cout << " label " << label << endl;
//drawing green rectagle in recognize face
rectangle(original, face_i, CV_RGB(255, 0, 0), 1);
string text = "Opredelen";
if (label == 1){
//string text = format("Person is = %d", label);
Pname = "Alexey";
}
if (label == 2){
Pname = "Tanya";
}
if (label == -1 || label == 0){
Pname = "Neizvestniy";
}
int pos_x = std::max(face_i.tl().x - 10, 0);
int pos_y = std::max(face_i.tl().y - 10, 0);
//name the person who is in the image
putText(original, text, Point(pos_x, pos_y), FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(255, 0, 0), 1.0);
//cv::imwrite("E:/FDB/"+frameset+".jpg", cropImg);
}
putText(original, "Kadrov: " + frameset, Point(30, 60), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(255, 0, 0), 1.0);
putText(original, "Imya: " + Pname, Point(30, 90), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(255, 0, 0), 1.0);
//display to the winodw
cv::imshow("IDC_STATIC", original);
//cout << "model infor " << model->getDouble("threshold") << endl;
}
if (waitKey(30) >= 0) break;
}
}
And right after the end of the while loop programm throws app crash with the folowing information:
Problem name: APPCRASH App name: sdkDemo.exe App version: 1.0.0.1 Timestamp: 56900b92 Error module name: StackHash_cf76 Version of error module: 6.1.7601.17725 Error module timestamp: 4ec49b8f Exception code: c0000374
Help me to find out the problem please...
Also run the cmd /scannnow procedure. Evrythink is ok with dlls and system files...