Re: Moving/resizing a window in real-time




 
Hi Alex,

The OpenCV window_gtk.cpp isn't so simple. A lot of tough concepts there. For example the code is written for 
compiling with both GTK2 and GTK3, makes use of threads, creates a custom GTK widget, uses GTK OpenGL if it 
can, etc. 

The GTK functions can only be called on the "main" thread of the program. This means that the OpenCV drawing 
can happen on a worker thread and you can keep track of the worker thread progress with the use of locking. 
When OpenCV is done you can notify the GTK main loop it is done and update the window. The following shows 
how something like this might work in a little simpler program.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/mandelbrot1.c

Have you made custom widgets with GTK? You can incorporate threads and the functionality that you are looking 
for and build it into a widget. There is an experimental gauge widget that draws on a separate thread at the 
following. That way the gauge drawing only gets redrawn entirely when the window gets resized. Speeds things 
up when using a frame clock and multiple gauges. Causes some screen flicker though on resizes.

https://github.com/cecashon/OrderedSetVelociRaptor/tree/master/Misc/AdjustableGauge2

For real-time or smooth window moves you can use a frame clock or a timer to check if you need to move your 
window. A lot of options to build what you want.

Eric

 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]