OpenCV mat::at throwing exception

Viewed 8335

This code only throws an exception in Debug mode. In Release, it gives the expected output of 0.

#include <opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(){
    Mat image;
    image = Mat::zeros(5,5,CV_8UC1);
    try{
       cout<< image.at<unsigned int>(1,1)<<"\n";
    }
    catch(Exception ex){
       cout<< ex.msg;
    }
    cin.get();
    return 0;
}

The text of the exception thrown is

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channel s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3 ) - 1))*4) & 15) == elemSize1()) in unknown function, file c:\users\tim\document s\code\opencv\build\include\opencv2\core\mat.hpp, line 537

Version of OpenCV is 2.4.6, and the executable is dynamically linked to the debug library.

1 Answers
Related