void onMouse(int event, int x, int y, int flags, void* param)
{
// Mat *pMat = (Mat*)param;
// Mat image = Mat(*pMat);
Mat image(512, 512, CV_8UC3, Scalar(255, 255, 255));
Vec3b planes = image.at<Vec3b>(y, x);
switch (event)
{
case EVENT_LBUTTONDOWN:
cout << "(" << y << "," << x << ") = (" << planes.val[0] + '0'<< ", " << planes.val[1] + '0' << ", " << planes.val[2] + '0' << ")" << endl;
}
}
I tried to get each value of RGB colors, but the appropriate value didn't show up. Instead, it showed up like some characters such as '↓' '┐' these things. Therefore, I simply add '0' to the end of the variable planes.val[0], so the result number came out, but the problem is the number went up to 303(instead of 255).
And by applying some unexpected step, I finally get a right value.
I add -'0' to the end, (so it is => planes.val[0]+'0'-'0' )(instead of planes.val[0] or planes.val[0]+'0') and now I can get the right value.
But, I don't know why this happens.