Ask Your Question
0

mouse wheel delta

asked 2017-02-17 19:56:56 -0600

JimboStlawrence gravatar image

Hi,

I've been using OpenCV 2.x for a few years and have now installed and integrated version 3.2. I'd like to be able to detect and determine the mousewheel direction. I'm not a professional C++ programmer but getting by. Currently, I have callbacks that take care of mouse buttons, CTRL, SHIFT etc. :

 void CallBackFunc(int event, int x, int y, int flags, void* userdata)
 {
    if ( event == cv::EVENT_LBUTTONDOWN) // 
    {
        mouse_click2 = 17;
        mouse_x = x;
        mouse_y = y;
    }

    if ( event == cv::EVENT_LBUTTONUP) // 
    {
        mouse_click2 = 18;
        mouse_x = x;
        mouse_y = y;
    }
 }

etc.....

How do I implement mouse wheel? I read in the documentation that I should use CV_GET_WHEEL_DELTA but no idea how to do this...

I know that:

 if (event == cv::EVENT_MOUSEWHEEL)
 {
   code...
 }

works i.e. it detects a movement of the wheel, but not sure how to measure the direction, or magnitude.

Any code examples would be greatly appreciated!

Thank you in advance.

Jimbo

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-17 21:50:46 -0600

LBerger gravatar image

you can try this sample and write something like this :

if (event==EVENT_MOUSEWHEEL)
{
    if (getMouseWheelDelta(flags)>0)
        rObs += (float)0.1;
    else
        rObs -= (float)0.1;
}

In this sample distance scene camera s increase or decrease

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-17 19:56:56 -0600

Seen: 5,261 times

Last updated: Feb 17 '17