CascadeClassifier DetectMultiScale Error (C++)
include "stdafx.h"
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
/** Function Headers */
/** Global Variables */
String face_cascade_dir = "haarcascade_frontalface_default.xml";
CascadeClassifier face_cascade;
int main(void)
{
// --1: Load Cascades.
if (!face_cascade.load(face_cascade_dir))
{
printf("(!)Error loading cascade.\n");
system("pause");
return -1;
}
// --2: Load Image.
Mat image = imread("rosto_frontal.jpg",CV_LOAD_IMAGE_UNCHANGED);
if (image.data == NULL)
{
printf("(!)Error while loading image file.\n");
system("pause");
return -1;
}
namedWindow("Loaded Image", CV_WINDOW_AUTOSIZE);
imshow("Loaded Image", image);
// --3: Preproccess Image.
Mat gray;
cvtColor(image, gray, COLOR_BGR2GRAY);
equalizeHist(gray, gray);
resize(gray, gray, Size(800,640), 0, 0);
namedWindow("Proccessed Image", CV_WINDOW_AUTOSIZE);
imshow("Processed Image", gray);
// --4: Apply Classifier.
vector<Rect> faces;
face_cascade.detectMultiScale(gray, faces, 1.1, 3, CASCADE_SCALE_IMAGE, Size(60, 60));
system("pause");
destroyAllWindows();
return 0;
}
Ok. There is my code. It runs fine until it reaches the detectMultiScale function and crash. I get the following message in the application console:
OpenCV Error: Assertion failed (!std::numeric_limits<_Tp>::is_integer || width == 0 || result / width == height) in cv::Rect_<int>::area, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\include\opencv2/core/types.hpp, line 1751
I've searched everywhere for an awnser. Couldnt find one. Any help would be appreciated. Thank you.
Edit: I am using OpenCV 3.3
Check lib when you link your program : in debug link with debug library