此代码仅在调试模式下引发异常.在Release中,它给出了预期的输出0.
#include#include using namespace cv; using namespace std; int main(){ Mat image; image = Mat::zeros(5,5,CV_8UC1); try{ cout<< image.at (1,1)<<"\n"; } catch(Exception ex){ cout<< ex.msg; } cin.get(); return 0; }
抛出的异常文本是
OpenCV错误:断言失败(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())在未知函数中,文件c:\ users\tim\document\code\opencv\build\include\opencv2\core\mat.hpp,第537行
OpenCV的版本是2.4.6,可执行文件动态链接到调试库.