How to Use C++/Qt/QML/OpenCV to Write Mobile Applications

I have avoided using QML for long time and always wrote even the most simple applications using Qt Widgets and C++ code but the release of Qt’s Quick Controls 2 and Material Style just made it very irresistible and I had to go for it. Well it didn’t take too long to get a hold of things (for a newcomer) since I had enough programming experience and QML is just too well-structured and easy to learn and use. In this post I’m going to share a project that demonstrates using OpenCV in QML to write beautiful and powerful Android (and other platforms) apps.

Continue reading “How to Use C++/Qt/QML/OpenCV to Write Mobile Applications”

Diffuse Shading in OpenGL Using Qt

This one is taken from one of my favourite books (OpenGL 4.0 Shading Language Cookbook) and the relevant chapter’s title for this tutorial in the book is called “Implementing diffuse, per-vertex shading with a single point light source”. Of course it’s modified to use OpenGL ES in Qt which is more cross-platform and creates less issues with building and running on different operating systems (including Android and iOS)

Continue reading “Diffuse Shading in OpenGL Using Qt”

How to Read Wavefront OBJ Files Using C++/Qt

First of all let’s briefly go through what’s an OBJ File. Here’s a very brief description from Wikipedia: “OBJ (or .OBJ) is a geometry definition file format first developed by Wavefront Technologies for its Advanced Visualizer animation package. The file format is open and has been adopted by other 3D graphics application vendors.” Anyway, I’ll assume that now that since you’re here you already know what an OBJ File is and How and Where to use it.

Continue reading “How to Read Wavefront OBJ Files Using C++/Qt”

How to Show a Toast Message in Qt for Android

If you’re a regular Qt user (like me) and have tried writing Android applications with Qt then you must have come across situations where you’ve needed some very simple capabilities of Android API but it wasn’t present in the Qt library. Displaying a Toast message in Qt for Android is one of those situations. In this post I’m going to describe how to display Toast messages in Qt for Android, and it’s also a very good example of showing how to use JNI (QAndroidJniObject class in Qt, along with Java code) to access Java code from within C++/Qt code.

Continue reading “How to Show a Toast Message in Qt for Android”

Best Way to Train and Test Haar or LBP Classifiers


You can use Cascade Trainer GUI to easily train and test your cascade classifiers. It has a very simple user interface which helps with everything  related to training cascade classifier that are usable with OpenCV. Starting from preparing the positive and negative image data set, its cropper tool will help you with quickly preparing your training data set. Just make sure you have enough videos of the object you want to train a classifier for, and detect. It also allows avoiding all the complexities of setting parameters for the training. Of course if you want a very high quality classifier, then you’d have to touch a few parameters here and there but for the most part, it’s select and Go.

You can use the Train tab to train a classifier, and then use the Test tab to test it on a video or image. And switch between them as long as you’re not satisfied with your classifier’s performance.

You can always download the latest version of Cascade Trainer GUI from its official website, or by clicking here.

And make sure to report any bugs and missing features using the Contact Me page.

How to Get Current App Version in Qt

I have tried numerous methods to get an application’s own version number and believe me this is the best way to get it. First of all if we consider the fact that setting a Qt application version is done in PRO file (qmake) using the following simple command:


Then getting this same value should be the easiest possible method.

Just add the following line to your PRO file after defining version as seen above and you can use the same version string wherever you like in the code:


APP_VERSION will contain the string “” and can be used in the C++ code.

Qt Creator Issue on Mac OS X Fix (xcodebuild issue with Xcode 8.0)

When using Qt creator following error starts rising up when Xcode gets updated to version 8.0 and it’s because of a change that is not yet applied in Qt settings. In my case it happened with Qt 5.7 and Xcode 8.0 on Mac OS X El Capitan but I think it’s safe to assume similar issues will start rising up with other kits too. Here is how I fixed it.

Continue reading “Qt Creator Issue on Mac OS X Fix (xcodebuild issue with Xcode 8.0)”

List of Image Formats Supported by OpenCV

Below is the list of supported image formats in OpenCV. You should note that if you build OpenCV yourself you have the option to remove support for some of the types but out of the box OpenCV supports the following:

  • Windows bitmap (bmp)
  • Portable image formats (pbm, pgm, ppm)
  • Sun raster (sr, ras)
  • JPEG (jpeg, jpg, jpe)
  • JPEG 2000 (jp2)
  • TIFF files (tiff, tif)
  • Portable network graphics (png)