Reputation: 2303
I'm developing an opencv app for the ios platform. I have opencv compiled by my self for debug and release schemes, but when I try to run the cv::meanStdDev
function with Debug scheme, the application fails 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 properly on Release scheme, but on Debug, it throws an exception like 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 a 'create' function of the matrix class.
In this point, the kind()
function gives different values in Debug and Release schemes for the same matrix. When Debug scheme is selected, because of the result of this kind()
function, the execution checks some data with a CV_Assert
function invocation, and then fails.
Any ideas? Someone know what can I check?
Upvotes: 4
Views: 3048
Reputation: 1510
Is this your entire program? If no, there is a possibility of heap corruption, which is very common on OpenCV due wrong access to Mat elements.
Ex:
Mat<uchar> mat(2,2);
mat.at<float>(1,1)=0.1;
If there is such code before the program segment you wrote, there may be a chance that your heap is corrupted, then you must fix it. On release mode you may be corrupting another area that does not interfere in this part of code, but in debug it looks like it does.
But if this is your entire code, i can't help too much... it looks right to me.
Upvotes: 4