Ask Your Question
-1

Moving Window With Mouse Using Imshow

asked 2017-12-03 19:09:06 -0600

jpistorino gravatar image

updated 2017-12-04 01:35:47 -0600

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

edit retag flag offensive close merge delete

Comments

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... ?

sjhalayka gravatar imagesjhalayka ( 2017-12-03 18:34:25 -0600 )edit

You can simply drag the titlebar, or use the standard right click on the icon and then click move.

EDIT: Merged duplicate questions.

Tetragramm gravatar imageTetragramm ( 2017-12-03 19:27:37 -0600 )edit

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?

jpistorino gravatar imagejpistorino ( 2017-12-03 20:04:59 -0600 )edit

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?

sjhalayka gravatar imagesjhalayka ( 2017-12-03 20:14:08 -0600 )edit

I am using VS2013 and built the libraries myself. VS2015 and 2017 did not work with CUDA 8.0.

jpistorino gravatar imagejpistorino ( 2017-12-03 20:18:26 -0600 )edit

You've done everything right, it seems. Are you running in a virtual machine, just curious?

sjhalayka gravatar imagesjhalayka ( 2017-12-03 20:22:35 -0600 )edit

No virtual machine. Thanks for any insight.

jpistorino gravatar imagejpistorino ( 2017-12-03 20:24:31 -0600 )edit

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!

sjhalayka gravatar imagesjhalayka ( 2017-12-03 20:28:03 -0600 )edit

Is your waitkey still running? Once it lets go, you can't move it any more. Try using waitKey(0).

Tetragramm gravatar imageTetragramm ( 2017-12-03 20:45:37 -0600 )edit

Yes, let's see your code.

sjhalayka gravatar imagesjhalayka ( 2017-12-03 21:09:00 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
-2

answered 2017-12-04 12:28:49 -0600

jpistorino gravatar image

Making waitkey(0) and deleting the getch call did it. Thanks very much.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-12-03 19:09:06 -0600

Seen: 3,428 times

Last updated: Dec 04 '17