critical bug when both mouse buton and mouse move is done (Bug #1437)
Description
as known when i hover the mouse over the image i opened in opencv window the cursor becomes a litle cross.
but when i use mousecalback with the eg. left button down kept down
the cross remains even if the mouse is away from the opencv window.
its not about thecross of course.but its about the funtions someone puts eg inside butondown and mouse mouve. so if the buton is down and kept down inside the picture ,it keeps calling the mouse mouve and button down functions even outside the window!!!!!!!!!
i used this mousecallback funtion
1void mouseHandler(int event, int x, int y, int flags, void *param)
2{
3 switch(event) {
4 /* left button down */
5 case CV_EVENT_LBUTTONDOWN:
6
7 fprintf(stdout, "Left button down (%d, %d).\n", x, y);
8
9 break;
10
11 /* right button down */
12 case CV_EVENT_RBUTTONDOWN:
13
14 break;
15
16 /* mouse move */
17 case CV_EVENT_MOUSEMOVE:
18
19 break;
20}
and when i move the mouse while i hold the button down ,starting from a place inside the image, if i continue to get it out of the image,or window,it keeps giving me coordinates outside the window.if i take it to the left it gives for x,large numbers 65000 or so.
Issue hierarchy
Associated revisions
Corrected bug #1437. Corrected the cast of two short values from an lParam. lParam contains two signed-short, the position can be negative when another mouse event happens with a mouse_move (mouse_click, etc.)
The Microsoft documentation specifies NOT to use LOWORD and HIWORD macros to extract the x/y positions as it won't work correctly with multiple monitors. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms645607(v=vs.85).aspx.
History
Updated by lowe nick over 13 years ago
so a code like
if(x > img0->width || y > img0->height)
break;
must be inside the mousemouve event. right??
Updated by lowe nick over 13 years ago
the mousehandler i wrote above is not the one i used. its the one here. but the problem is still there
void mouseHandler(int event, int x, int y, int flags, void *param) {
switch(event) {
/* left button down */
case CV_EVENT_LBUTTONDOWN:
break;
/* right button down */
case CV_EVENT_RBUTTONDOWN:
break;
/* mouse move */
case CV_EVENT_MOUSEMOVE:
fprintf(stdout, "mouve (%d, %d).\n", x, y);
break;
}
Updated by fbhaar - about 13 years ago
Hi I just posted a related defect:
#1523: defect: (x,y) bug in MouseCallback when image is larger than your screen (new)
What I notice is that the bug you describe only occurs when the image is larger than the screen. If the image is smaller x and y coords the MouseCallback function provides are fine.
good luck
Updated by Alexander Shishkov about 13 years ago
- Category set to highgui-images
Updated by Alexander Shishkov almost 13 years ago
- Description changed from as known when i hover the mouse over the image i opened in opencv window the ... to as known when i hover the mouse over the image i opened in opencv window the ... More
Updated by Alexander Shishkov almost 13 years ago
- Priority changed from High to Normal
- Target version deleted ()
Updated by Alexander Shishkov almost 13 years ago
- Assignee deleted (
Vadim Pisarevsky)
Updated by Alexander Shishkov almost 13 years ago
- Target version deleted ()
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-gui
Updated by David Rolland almost 11 years ago
I just had the same problem as described in this issue. Having the mouse events called even when the mouse is outside doesn't really bother me. What bothers me is that when the mouse cursor (with one button clicked) is outside the window the x and y positions are wrong. This only happens when the values should be negative. I debugged the problem and in HighGUIProc there are some missing casts:
pt.x = LOWORD;
pt.y = HIWORD;
What happens is that lParam contains two SIGNED short, so when the low or high part of lParam is negative the sign-bit isn't processed. Before putting the value in x or y, it should be cast to a signed short. I guess this bug doesn't happen often because the EVENT_MOUSEMOVE isn't called when the mouse cursor is outside the image. It is called only when another event is also triggered like a mouse button down.
This happens no matter if the image is bigger than the screen or not, as opposed to what fbhaar says here: http://code.opencv.org/issues/1437#note-3
Updated by Sergei Nosov almost 11 years ago
Hi, David!
Could you, please, consider submitting a Pull Request with a proposed fix to our GitHub repo (https://github.com/Itseez/opencv)?
- HW Platform set to Any
- Operating System set to Any
- Affected version set to branch '2.4' (2.4-dev)
Updated by David Rolland almost 11 years ago
Hello Sergei,
Sorry for the long delay for such a small change. I just created the pull request. Let me know if there's any problem.
Regards,
David
Updated by David Rolland almost 11 years ago
As version 2.4.9 as been released including my patch, I think this issue can now be closed. But I'm not sure what is the standard procedure for this.
Updated by Steven Puttemans almost 11 years ago
Put it on done for you ;)
- Target version set to 2.4.9
- Status changed from Open to Done