我有以下代码
void Segmentation::CallBackFunc(int event, int x, int y, int flags, void* param)
{
Vec3b bgrPixel;
int i = 0;
//Press 0, if face
if (event == EVENT_LBUTTONDOWN)
{
Mat &img = *((Mat*)(param)); // 1st cast it back, then deref
circle(img, Point(x, y), 3, Scalar(0, 255, 0), 2);
try
{
bgrPixel = img.at<Vec3b>(x, y);
}
catch (Exception ex)
{
string message = ex.msg;
}
imshow("Display window", img);
一切正常,直到我点击相对较亮的像素(例如白色)。在这种情况下,我收到以下例外:
error: (-215) dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0]
&& (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels())
&& ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()
in function cv::Mat::at