Installing OpenCV 2.4.9 + QT5 in Ubuntu

Installing OpenCV 2.4.9 + QT5 in Ubuntu

Hi,

Today is a small how to install OpenCV + QT5 in linux Ubuntu. For those who doesn’t know what is OpenCV, you can check here. Briefly OpenCV is a library for real time image processing created by Intel. It’s free for use under BSD license.

 

Installing QT

QT is a multiplataform application framework  developed by Digia. Some plataforms supported are: Android, Embedde Linux, iOS, Windows, Windows CE, etc.

To install QT:

 

Compiling OpenCV

First of all we need to install some required packages

Now, we get OpenCV here and we save it in a directory that we’ll call opencv5.

By default this library will be installed in /usr/local/lib. If you want to see some cmake options, read CMakeLists.txt.

In order to be able to link the lib, we need to create a file opencv.conf in /etc/ld.so.conf.d/ with the following:

and then execute

 

Testing OpenCV

If you want to test if everything is OK, you can go to the directory ./build/bin and execute one of several tests like:

 

QT5 + OpenCV together

First start QTCreator, in command line type

 

Create a new console project

 

new_project

 

Select Desktop as platform and follow the wizard until the end.

 

kit_selection

 

Now we need to tell to QT where we installed the libs. To do that open the .pro file and add the path.

Let’s test it and check if everything is working properly. In our OpenCV “hello world”, we’ll just show an image, of course, lena. You need to copie it in your project in Debug folder if you are in debug or Release if you are in release mode.

Below is our “hello world” code.

Compile and run and if everything is perfect, we should have this image

 

lena_result


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章