UPDATE: If you’re trying to compile opencv look at this article.
This is a quick post to answer a simple question that I have seen floating around the web with no definitive answer, using OpenCV in QTcreator.
Note: Check out this other post for using OpenCV 2.2 in QTCreator within Windows.
Note: Check out this new library for easily creating custom iterators blIteratorAPI
First off, stating the obvious, OpenCV is a state of the art open source library for image analysis from Intel, easy to use, and with a vast amount of tools that have been built up since its inception.
QTCreator is the open source cross-platform IDE from Nokia’s QT project, and with its ease of use, complete integration with the QT library, and included compiler, it has proven to be a complete solution.
For those of you that would love to use the OpenCV library from the QTCreator IDE, it turns out to be very simple. Just follow the simple instructions below (if you already have OpenCV and QTCreator installed on your machine, just skip to step 3):
- Download both OpenCV and QTcreator, which can be found by clicking on the links.
- Install both OpenCV and QTcreator, specifying installation directories and so forth. (I suggest just to let the automatic installation do its thing, and jog down the directories where OpenCV was installed).
- Restart the computer — This step is required for the PATH to be registered. Trust me it will save you a huge headache.
- Run QTCreator
- Start a New Project (File -> New File or Project… Then pick a QT C++ project, could be QT application or Console application, then follow the instructions to create the new project)
- Now that you have a new project, you should have a view like the figure below.
- All you have left to do, is to add the INCLUDEPATH and LIBS lines to your pro file, like the ones shown in the figure below, but remember to use the actual directory where you installed OpenCV. (Backward slashes “\” are used to add multiple lines)
Troubleshooting List, to be built as I get feedback:
- Error — “exited with code – 1073741515” (or something along those lines)
- You probably missed Step 3. — Restart the computer after installation of OpenCV, (a quick restart should resolve the problem).
- If you still get the error after restarting, then copy the OpenCV dlls from the OpenCV2.0\bin directory to the Windows\system32 directory if in 32bit version of windows or to the Windows\SYSWOW64 directory if in 64bit version of windows.
- If you still get the error after step 1 and step 2, then you’re missing some Microsoft dlls. It turns out that the “release” version of opencv works right out of the box. But the “debug” version of opencv does not. It has some dependencies on some Microsoft dlls.
- [SOLVED] — It turns out that the Microsoft dlls are downloaded as part of the visual c++ express package. So as a solution, download and install the bare-bones visual c++ express and the “debug” version of opencv will work. (You don’t have to use visual c++ express, you can still use QTcreator and the Mingw compiler, it will work, trust me)
Note: If you have a chance, check out the BarbatoLabs Image API, blImageAPI. It’s a very simple but powerful API, which is based on opencv’s IplImage and boost::shared_ptr, and gives you automatic garbage collection and memory allocation/deallocation and other good stuff, while being 100% compatible with opencv’s existing algorithms, it can be used instead of IplImage or interchangeably with it.