0

I am displaying some images with imshow and waitKey() only works when I click the window after it has opened. Is there any way to do this automatically so I do not have to click it everytime?

Lager159
  • 11
  • 2
  • 2
    This is more related to how your platform handles new windows. This question might be relevant https://stackoverflow.com/questions/8417531/opencv-how-to-force-the-image-window-to-appear-on-top-of-other-windows . – Paul92 Apr 13 '19 at 14:18
  • On Linux (and other Unix operating systems) there's usually a way to request the window manager to bring a window to the front. On (modern) Windows OSs you cannot do that. – Jesper Juhl Apr 13 '19 at 14:21

1 Answers1

1

SOLVED: Do this before using waitKey() to create a window "My Image" and focus it"

namedWindow("My Image", WINDOW_NORMAL);

HWND windowHandle = FindWindow(NULL,_T("My Image"));
SetForegroundWindow(windowHandle);

(#include<tchar.h> for _T)

Lager159
  • 11
  • 2