Why cv :: meanStdDev does not work with debugging error

I am developing an opensv application for the ios platform. I have opencv compiled by me for debugging and release schemes, but when I try to run the cv::meanStdDev function using the debugging scheme, the application crashes with an exception (with Release it works fine). The test function is very simple:

 float list[] = {1.2,1.2,1.3,0.3,6.5,2.2,0.9,0.8,0.9}; cv::Mat test(1,9,CV_32F, list); cv::Scalar mean1, stddev1; cv::meanStdDev(test, mean1, stddev1); printf("[%f, %f]", mean1.val[0], stddev1.val[0]); 

This function works correctly in the Release schema, but in Debug it throws an exception similar to this:

 OpenCV Error: Assertion failed (dims == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) || (allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height))) in create, file /Users/jgoenetxea/libraries/OpenCV-2.4.0/trunk/opencv/modules/core/src/matrix.cpp, line 1375 terminate called throwing an exception 

This line is the "create" function of the matrix class. At this point, the kind() function gives different values ​​in the debug and release circuits for the same matrix. When a debugging scheme is selected, due to the result of this kind() function, the execution checks some data with a call to the CV_Assert function, and then fails.

Any ideas? Does anyone know what I can check?

+4
source share
1 answer

Is this your whole program? If not, there is a possibility of heap damage, which is very common in OpenCV due to incorrect access to Mat elements.

Example:

 Mat<uchar> mat(2,2); mat.at<float>(1,1)=0.1; 

If there is such code before you write the program segment, it may be that your heap is damaged, then you should fix it. In release mode, you can corrupt another area that does not interfere with this part of the code, but it looks like this when debugging.

But if this is your entire code, I cannot help too much ... it looks right to me.

+4
source

All Articles