Debug assertion failed std::vector crashes on deallocation for CascadeClassifier::detectMultiScale
I am using this function to detect faces:
void FaceDetector::findFacesInImage(const Mat &img, vector<Rect> &res) {
Mat tmp;
int width = img.size().width,
height = img.size().height;
Size minScaleSize = Size(_minSizeRatio * width, _minSizeRatio * height),
maxScaleSize = Size(_maxSizeRatio * width, _maxSizeRatio * height);
//convert the image to grayscale and normalize histogram:
cvtColor(img, tmp, CV_BGR2GRAY);
equalizeHist(tmp, tmp);
//clear the vector:
res.clear();
//detect faces:
_cascade.detectMultiScale(tmp, res, _scaleFactor, _minNeighbors, 0, minScaleSize, maxScaleSize);
}
And this function is called in the main(), it works perfectly on release mode. However in debug, when the codes finish and calls the destructor for vector<rect> res. It gets a debug assertion error.
check debug libs : opencv libs in debug must be opencv_xxxxxx330d.lib for opencv 3.3
maybe related to this issue
@Santiago-Molina , we need to know, IF you're using visualstudio. because, if so, -- accidentally mixing debug build and release libs (or the other way) is commonly the reason for this problem.
Thanks for your answers. I am using visual studio, but the problem is not related to mixing debug and release libs. It can be more relared to the issue pointed by @sturkmen. By the way I am using OpenCV 2.4.13