- Navigate to the OpenCV website and download the latest binaries/source for Windows, and extract them somewhere for ex. C:yourOpencvDirectory
- NOTE: In your extracted directory, you should have two sub-directories called “build” and “sources”:
- Navigate to the CMake website and download the latest CMake Windows Installer and install CMake (when asked, I chose to add CMake to the path for all users).
- Launch CMake GUI, here’s what the GUI should look like:
- In the GUI, pick the source directory and the directory where your compiled OpenCV build will be installed, and the hit the “Configure” button:
- After clicking the “Configure” button, you’re presented with the following window, where you have to pick which Makefiles to generate. In my case I picked the MinGW Makefiles:
- Then, in the next window you have to find the compilers on your computer, for example on my computer I specified where the MinGW compilers for both C and C++ are:
- After you’ve picked your compilers, you might get errors, that’s ok, just hit the “Configure” button one more time, and CMake will start configuring the build:
- Once the configure process is done, you’ll be presented with choices for your build, I left everything as is, and then when you’re ready to build, you click the “Generate” button:
- We’re almost there. CMake should have generated the Makefiles. Now open up a command prompt and go to your opencv build directory, and simply type the command “mingw32-make” (without the quotes) and hit enter:
- Now, sit back and relax, because this is going to take a while (look mine is at only 2%, man this is not going to be quick):
- It’s DONE!!!
After it’s done, we’re now ready to use the libraries in our projects, let’s see what we need to do to use it in QTcreator. In your QTcreator project, in the “.pro” file, we’re going to add the path to the include directory, as well as link to the opencv libraries. The process is the same for whichever version of Opencv you have just built. The following snippet shows the lines to add I added to my project’s “.pro” file, you can see I decided to add every library from opencv:
INCLUDEPATH += C:/opencv/build/include
LIBS += C:/opencv248/build/x86/mingw/lib/libopencv_calib3d248.dll.a
Don’t forget to check out my blImageAPI library that makes working with opencv much more intuitive. (By the way, I’m about to release a new version of the blImageAPI library any day now, so check back, I’ll put it up on github)
GOOD LUCK and have fun programming!!!