Moving Window With Mouse Using Imshow
I am using OpenCV 3.3 on a Win10 platform with C++.
Is there a way to enable the mouse to move a window shown with Imshow? I do see that there is a mouse callback function nut that seems more targeted at using mouse events to control an app rather than simple window control.
I wonder if this is something I am missing because this seems elemental.
If a callback function is required, any example code for moving a window appreciated.
Here is the relevant portion of my code:
namedWindow("CPU window", WINDOW_NORMAL);// Create a window for display.
moveWindow("CPU window", 0, 250);
resizeWindow("CPU window", 1920, 1080);
imshow("CPU window", tImage.MaskFrame);
cv::waitKey(30);
_getch();
Thanks
Can't you move imshow windows by clicking and dragging on the title bars?
Or are you talking about this: https://opencv-srf.blogspot.ca/2011/1... ?
You can simply drag the titlebar, or use the standard right click on the icon and then click move.
EDIT: Merged duplicate questions.
Doesn't work. You can't select the title bar. Could be that I am using getch/waitkey? How else would you keep the window up?
That's abnormal behaviour. The whole point of waitKey is to let you move windows around before they disappear, which only occurs when a key is pressed. Are you using the latest Visual Studio Community Edition 2017? Did you use the pre-built .h/.lib/.dll files, or did you build them yourself?
I am using VS2013 and built the libraries myself. VS2015 and 2017 did not work with CUDA 8.0.
You've done everything right, it seems. Are you running in a virtual machine, just curious?
No virtual machine. Thanks for any insight.
Do you have an alternative OS to try it on? I'm running Mac OS X, but I also have an Ubuntu Linux virtual machine, and a Windows virtual machine. I use VirtualBox, from Oracle. You could always try the Ubuntu Linux virtual machine route, to see if works. If it does work in Ubuntu Linux, then I'd say there's a bug in your Windows graphics drivers. What a pain!
Is your waitkey still running? Once it lets go, you can't move it any more. Try using waitKey(0).
Yes, let's see your code.