Ask Your Question

Revision history [back]

My code :

    Mat com = (Mat_<uchar>(4, 3) << 1, 2, 3, 4, 5, 6, 255, 255, 0, 255, 255, 255);
    cout << int(com.at<Vec3b>(0, 0)[2]) << endl;
    cout << int(com.at<Vec3b>(0, 0)[3]) << endl;

really a bad code but it is for demo. com is a CV_8UC1 and not a Vec3b. Now in release result is :

3
4

Vec3b is only char* Now in debug :

3
OpenCV(4.1.0-dev) Error: Assertion failed ((unsigned)i < (unsigned)cn) in cv::Vec<unsigned char,3>::operator [], file G:\Lib\install\opencv\include\opencv2/core/matx.hpp, line 1116
4

opencv throw an exception

I think in release you can use setLog to throw an exception