I am currently developing an application that needs to be able to both use OpenCV (computer vision library) optimally, and at the same time offer the user a nice graphical interface, all on ubuntu linux. thus far i have tried to integrate gtkmm and opencv using pthreads - using one thread for the image capturing and processing, and another for the graphical user interface. this has not worked, however, as it seems that using gtkmm in conjunction with pthreads is a no-go: while the thread with the GUI starts up fine, the thread initialized second (containing the image processing procedures from OpenCV) does not proceed until the thread containing the GUI has been terminated.
does anyone know of a good way to integrate these two?
That high-level approach will work fine, but there are a few gotchas to watch out for. First of all, every GTKmm call which affects the GUI in any way must be made in the GUI thread. Under GTK+ I would have done this using g_idle_add(), but a cursory glance at the GTKmm docs doesn't show what the correct alternative is.
Second, you'll need to call Glib::thread_init() at the start of the program even though you're using pthreads rather than gthreads. This will cause certain functions to become multithreading-aware.