使用子弹进行解释,以便于阅读(希望如此):
OpenCV错误:setSize中的断言失败(0< = _dims&& _dims< = CV_MAX_DIM),文件/tmp/opencv-0tcS7S/opencv-2.4.9/modules/core/src/matrix.cpp ,89行 libc ++ abi.dylib:以cv类型的未捕获异常终止::异常:/tmp/opencv-0tcS7S/opencv-2.4.9/modules/core/src/matrix.cpp:89:错误:(-215)0 < = _dims&&函数setSize中的_dims< = CV_MAX_DIM
这是我的代码:
void draw(int event, int x, int y, int flags, void* params){
ImgData* input = (ImgData*)params; //Convert the struct passed in as void to a ImageData struct.
if(event == EVENT_LBUTTONDOWN){
printf("Left mouse button clicked.\n");
input->ipt = Point(x,y); //Store the initial point, this point is saved in memory.
printf("Original position = (%i,%i)\n",x,y);
}else if(event == EVENT_LBUTTONUP){
cv::Mat temp_canvas;
input->getCanvas().copyTo(temp_canvas);
printf("Left mouse button released.\n");
input->fpt = Point(x,y); //Final Point.
cv::rectangle(temp_canvas, input->ipt, input->fpt, Scalar(200,0,0));
input->setCanvas(temp_canvas);
}
}
我尝试这样做的方法是从对象实例复制画布,在此副本上绘制矩形,然后用这个修改过的画布覆盖旧画布。
任何有关此问题的帮助或解释为何会发生这种情况将不胜感激。
谢谢
答案 0 :(得分:0)
我已经解决了这个问题,只是因为我没有正确地传递这个对象:
setMouseCallback("Window", draw, &images->at(imageShown)); // replaced the code: setMouseCallback("Window", draw, &images[imageShown]);
愚蠢的错误......