Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::vector crashes on deallocation

After downloading the latest version of OpenCV, I'm having a problem where using certain functions that output values to a cv::vector crashes when the vector destructor is called. For example, the following snippet crashes at delete x:

#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char *argv[])
{
    int size = 512;
    cv::vector<Point> *x = new cv::vector<Point>();
    Mat m(1, size, CV_8U, Scalar(128));
    findNonZero(m, *x);
    delete x;
}

Interestingly, if size is less than 512, everything works fine.

Now, I suppose maybe findNonZero should output to a Mat instead of a vector, but this code worked in the past. Furthermore, I'm seeing similar effects with CascadeClassifier::detectMultiScale which expects to output to a vector<Rect>.

The error messages indicate an access violation. When running in a Debug configuration, I get assert fail errors. Everything happens in the vector destructor.

I've tried running with different architectures and various other settings. I will try reinstalling OpenCV by building it from the source. It's just I've been at this bug for a whole day, and I would greatly appreciate if anyone could give me some insight about what to do.

Thanks.

cv::vector crashes on deallocation

After downloading the latest version of OpenCV, I'm having a problem where using certain functions that output values to a cv::vector crashes when the vector destructor is called. For example, the following snippet crashes at delete at the end of the code as x: falls out of scope:

#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char *argv[])
{
    int size = 512;
    cv::vector<Point> *x = new cv::vector<Point>();
x;
    Mat m(1, size, CV_8U, Scalar(128));
    findNonZero(m, *x);
    delete x;
x);
}

Interestingly, if size is less than 512, everything works fine.

Now, I suppose maybe findNonZero should output to a Mat instead of a vector, but this code worked in the past. Furthermore, I'm seeing similar effects with CascadeClassifier::detectMultiScale which expects to output to a vector<Rect>.

The error messages indicate an access violation. When running in a Debug configuration, I get assert fail errors. Everything happens in the vector destructor.

I've tried running with different architectures and various other settings. I will try reinstalling OpenCV by building it from the source. It's just I've been at this bug for a whole day, and I would greatly appreciate if anyone could give me some insight about what to do.

Thanks.

cv::vector std::vector crashes on deallocation

After downloading the latest version of OpenCV, I'm having a problem where using certain functions that output values to a cv::vector std::vector crashes when the vector destructor is called. For example, the following snippet crashes at at the end of the code as x falls out of scope:

#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char *argv[])
{
    int size = 512;
    cv::vector<Point> std::vector<Point> x;
    Mat m(1, size, CV_8U, Scalar(128));
    findNonZero(m, x);
}

Interestingly, if size is less than 512, everything works fine.

Now, I suppose maybe findNonZero should output to a Mat instead of a vector, but this code worked in the past. Furthermore, I'm seeing similar effects with CascadeClassifier::detectMultiScale which expects to output to a vector<Rect>.

The error messages indicate an access violation. When running in a Debug configuration, I get assert fail errors. Everything happens in the vector destructor.

I've tried running with different architectures and various other settings. I will try reinstalling OpenCV by building it from the source. It's just I've been at this bug for a whole day, and I would greatly appreciate if anyone could give me some insight about what to do.

Thanks.