From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

kl3m3n's blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCV and Qt based GUI (Hough circle detection example)

Klemen
Active Participant

Hello,

I had some free time and I've decided to test an alternative to Labview GUI for image processing tasks. Many of my previous posts talk about using various OpenCV functionalities in Labview via .dll function calls.This involves some additional (but fairly straightforward) work to properly setup the call library function node. For this example, I used Qt framework (http://www.qt.io/developers/), which uses the standard C++ with some additional functionalities. Qt is mainly used for GUI development, but is also an alternative to Visual Studio (non-qt applications can also be made, such as console applications).

Today, I tested a small program using OpenCV and Qt (community version). The program is basically a GUI with some indicators and controls that can be used to modify a few parameters for real-time object detection using Hough circle transformation. The image below explains this better.

QtOpenCV_example.png

Figure 1. GUI for real-time circle detection visualization.

The horizontal sliders are used modify the threshold of the RGB (BGR) image. This can be used to track object of different colors (I chose the settings based on experimental values). The indicators B,G,R show the threshold ranges for each color plane. Additionally, there are four controls to tweak the circle detection (see OpenCV documentation for further explanation). The parameters can be modified at runtime and are confirmed by pressing the 'enter' or 'return' key. The indicator on the far right shows the position and the radii of the detected circles.

First of all, to get OpenCV working with Qt, you need to include the dependencies, which is in my opinion even easier than in Visual Studio. All include paths go in the same file, which makes the dependencies very readable. See the file with the ".pro" extension in the attachment. Also, add the OpenCV's 'bin' path to system path (straightforward, but if you have problems, see previous posts). The code is in the attachment.

The next thing I will work on is displaying the Kinect data stream (color and depth image and hopefully also 3D).

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Comments