i’ve just encountered a strange problem. In the header of my class I have defined multiple cv::Mat like this:
cv::Mat drawing, img_grad, img_bright, img_cov; (ver1)
cv::Mat drawing, img_grad, img_bright, img_cov, img_notused; (ver2)
In the code i then define img_cov as the following:
img_cov = Mat::zeros( somemat.size(), CV_32FC(6) )
Strange thing is that if i add another Mat to the header declaration (see ver2 above) of my multiple Mats that, even if img_notused it is never used, i am not able to access any other channel of my img_cov than 0. Accessing e.g. via img_cov.at<float>( j, i, 1) leads to a crash.
Seems to be a mermoy-allocation thing. Could someone explain this to me?
You use a wrong command to access the image values (it should have crashed earlier on, maybe you compile in release mode…).
Your line should look like this:
because
CV_32FC(6)means a 6-channel matrix withfloatvalues in the channels.For your reference: link to specific docs