c++ - opencv在访问像素点时终止运行
大家讲道理
大家讲道理 2017-04-17 15:30:29
0
2
579

我进行这样的操作:
image_backup_.at<Vec3b>(xpos + i, ypos + j - 1)[k]
就会终止程序,然后debug下发现call stack:定位到上一行image_backup_.at<Vec3b>(xpos + i, ypos + j - 1)[k]

CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]);

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
阿神

The parameters of the at function are at (row, column), not x, y, so an out-of-bounds error occurs, and you need to replace the two.
If you must use x and y, you can use at(cv::Point(x,y)).
In addition, opencv will throw exceptions. You can use catch(std::exception e) to catch exceptions and view error information.

阿神

Function named at generally has bounds checking. The check here is implemented through assertions, namely CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]);. According to the expression semantics, the reason for assertion failure is that the coordinates are out of bounds "i>=size".

Please check the value range of xpos + i and ypos + j - 1. Note: Due to unsigned conversion during checking, values ​​less than 0 will become a larger value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template