6

Here's a simplified version of my app:

Mat img = imread("./picture.png");
namedWindow("Picture", CV_WINDOW_AUTOSIZE);
imshow("Picture", img);
waitKey(0);

When I execute the compiled app (on a MacOS 10.8.2 with OpenCV 2.4.3) the window is opened underneath the terminal window and is not in focus. So, I have to first click on (or tab into) it, and then can hit any key for the waitKey to be done.

Is it possible to bring the cv::namedWindow into focus automatically?

Yuriy Nemtsov
  • 3,869
  • 4
  • 30
  • 44
  • 1
    see: http://stackoverflow.com/questions/8417531/opencv-how-to-force-the-image-window-to-appear-on-top-of-other-windows or http://stackoverflow.com/questions/5960968/opencv-window-always-on-top?lq=1 – Smash Jan 10 '13 at 20:57
  • I see. So, based on these the answer is, either 'no' or 'use cvGetWindowHandle' (which appears to be deprecated in OpenCV2; at least I can't find it anywhere in the docs) and then find out what MacOS does for window-management and write some ugly platform-specific code. I suppose that's understandable, since the highgui wasn't meant as a robust windowing framework. – Yuriy Nemtsov Jan 10 '13 at 22:12

1 Answers1

0

You can probably enumerate all the windows and compare their titles with your own window title. I'm not sure how to do it in MacOS but under Windows, there is an API that does this job for you: EnumWindows().

Since OpenCV 2.x still supports lots of old C style functions, you can probably check if cvGetWindowHandle() is still included.

james
  • 1,107
  • 14
  • 29