Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to get the pixel value by clicking on image?

Hi all, I am able to get the pixel coordinate by clicking on image with setmousecallback function. I want to return the pixel value of that coordinate. But I am getting some error. Please, check the below code. xyz matrix contain the depth information. Thank you.

setMouseCallback("cascade_image", onMouse, &rxyz);

static void onMouse(int event, int i, int j, int flags, void* param, Mat &xyz) {

if (event == EVENT_LBUTTONDOWN)
{
    short val = xyz.at< short >(i,j); 
    cout << "x= " << i << " y= " << j << "val= "<<val<< endl;
}

}

click to hide/show revision 2
No.2 Revision

updated 2017-08-02 03:09:09 -0600

berak gravatar image

how to get the pixel value by clicking on image?

Hi all, I am able to get the pixel coordinate by clicking on image with setmousecallback function. I want to return the pixel value of that coordinate. But I am getting some error. Please, check the below code. xyz matrix contain the depth information. Thank you.

setMouseCallback("cascade_image", onMouse, &rxyz);

&rxyz);

static void onMouse(int event, int i, int j, int flags, void* param, Mat &xyz) {

{
 if (event == EVENT_LBUTTONDOWN)
 {
  short val = xyz.at< short >(i,j);
  cout << "x= " << i << " y= " << j << "val= "<<val<< endl;
 }
}

}

how to get the pixel value by clicking on image?

Hi all, I am able to get the pixel coordinate by clicking on image with setmousecallback function. I want to return the pixel value of that coordinate. But I am getting some error. Please, check the below code. xyz matrix contain the depth information. Thank you.

setMouseCallback("cascade_image", onMouse, &rxyz);

static void onMouse(int event, int i, int j, int flags, void* param, Mat &xyz)
{

    if (event == EVENT_LBUTTONDOWN)
    {
        short val = xyz.at< short >(i,j); 
        cout << "x= " << i << " y= " << j << "val= "<<val<< endl;
    }
}