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.
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
andypos + j - 1
. Note: Due to unsigned conversion during checking, values less than 0 will become a larger value.