1

I have a c++ console application which creates an opencv window.

I'm using cvWaitKey(1) in order to catch keyboard key presses.

Here's what I would like to do:

When the user presses the s key, I would like him to type-in something in the console. However, for that, after pressing s he needs to manually click the console window (in order to put the focus on it), and then he can type in the text.

Is it possible to transfer the focus to the console which generated the opencv image, and then transfer it back to the opencv window?

Idanis
  • 1,918
  • 6
  • 38
  • 69
  • thats probably possible with your window management API (for example WinAPI on windows systems) or with high level gui libraries like qt, but I doubt it to be possible with openCV since openCV isnt made for gui programming and only gives some nice functionality for some fast and easy temporary gui to test your code – Micka Jun 11 '14 at 13:49

1 Answers1

2

For windows check

HWND WINAPI GetConsoleWindow(void);

,

HWND WINAPI FindWindow(
  _In_opt_  LPCTSTR lpClassName,
  _In_opt_  LPCTSTR lpWindowName
);

and

BOOL WINAPI SetForegroundWindow(
  _In_  HWND hWnd
);

methods.

Opencv windows have "HighGUI class" class name.

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42