Debug assertion failed std::vector crashes on deallocation for CascadeClassifier::detectMultiScale

asked 2017-09-21 10:38:06 -0500

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:

//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.

edit retag flag offensive close merge delete


check debug libs : opencv libs in debug must be opencv_xxxxxx330d.lib for opencv 3.3

LBerger gravatar imageLBerger ( 2017-09-21 12:22:05 -0500 )edit

maybe related to this issue

sturkmen gravatar imagesturkmen ( 2017-09-21 14:03:11 -0500 )edit

@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.

berak gravatar imageberak ( 2017-09-22 10:50:53 -0500 )edit

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

Santiago-Molina gravatar imageSantiago-Molina ( 2017-09-27 10:56:03 -0500 )edit