g_capture >> frame;
if( frame.empty() ) break;
cv::imshow( "Example", frame);
}
if( cv::waitKey(10)==27 ) break;
}
return 0;
}
You can see that this will turn on and off just like a light switch. In our example, whenever the trackbar
“switch” is set to 0, the callback executes the function switch_off_function(), and whenever it is
switched on, the switch_on_function() is called.
Working with the Qt Backend
As we described earlier, the trend in the development of the HighGUI portion of OpenCV is to rely
increasingly on a separate library for GUI functionality. This makes sense, as it is not OpenCV’s purpose to
reinvent that particular wheel, and there are plenty of great GUI toolkits out there that are well maintained
and which evolve and adapt to the changing times under their own development teams.
From the perspective of the OpenCV library, there is a great advantage to using such an outside toolkit.
Functionality is gained, and at the same time, development time is reduced (which would otherwise be
taken away from the core goal of the library).
However, an important clarification is that using HighGUI with the Qt backend is not the same as using Qt
directly (we will explore this possibility briefly at the end of this chapter). The HighGUI interface is still
the HighGUI interface; it simply uses Qt behind the ...