Ask Your Question

MariusUt's profile - activity

2020-10-04 02:48:51 -0600 received badge  Notable Question (source)
2018-05-21 03:55:51 -0600 received badge  Popular Question (source)
2015-06-12 02:26:24 -0600 commented answer std::vector crashes on deallocation

Nice spot :D When I said latest release, I meant the latest download from opencv.org, which I downloaded yesterday. I was intentionally being vague since the download also contained opencv_xxx249.dll files. I wasn't 100% sure which was the right one, but I decided to post here before checking; as I said, I've been at it a whole day, and I don't think it's unreasonable to post a question before exhausting every single option. At the time of writing, I have checked it though, and I am sure it uses 3.0. I'm now trying to download an older version and see if the problem is still there.

2015-06-11 10:34:25 -0600 commented answer std::vector crashes on deallocation

@theodore: Honestly, I'm not sure, I think it was a typedef for std::vector<>. Either way, I have updated my code to use std::vector<> instead, and the issue is still exactly the same.

2015-06-11 09:12:33 -0600 received badge  Critic (source)
2015-06-11 09:12:29 -0600 commented answer std::vector crashes on deallocation

I'm sorry, but that's not it. The code you provided has the same error; the crash happens at the end of main when the vector falls out of scope. The explicitly defined pointer was from another test I tried earlier. I've updated my question to reflect the problem, and I'm sorry for the confusion.

2015-06-11 09:10:14 -0600 received badge  Editor (source)
2015-06-11 08:53:10 -0600 asked a question 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 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;
    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.