You are not logged in.

#1 2016-07-07 15:15:33

bokiscout
Member
Registered: 2015-09-27
Posts: 24

[Solved] OpenCV and QT - search for libraries

I'm learning Open CV right now and I am facing with a problem. I don't know which libraries should be included (or excluded if not needed) based on the OpenCV functions I use. Note that I'm using QT Creator as IDE and QT framework for the front end.

Here is an example:
I include the folowing libraries in myprogram.pro in QT Creator:
"LIBS += -lopencv_video -lopencv_core -lopencv_imgproc -lopencv_objdetect -lopencv_highgui"

but the program can't compile due to error 'undefinded reference to cv::VideoCapture()'.

After few hours I realised that opencv_videoio was the library that was missing and after including it the program compiled and it is working just fine.

So my question is: Is there anything that can be done in order to find out which libraries are missing and should be included in easy way?

Last edited by bokiscout (2016-07-25 01:35:03)


What's the object-oriented way of becoming wealthy?
- Inheritance

Offline

#2 2016-07-19 21:42:36

xiouy
Member
Registered: 2016-07-19
Posts: 1

Re: [Solved] OpenCV and QT - search for libraries

Hey,

in a lot of cases you can see in the way you include the headers. So in the example of opencv:

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"

So in this case you will need imgproc and highgui. But the easier way to go would be to use pkg-config.
So it would look like this for opencv:

$ pkg-config --libs --cflags opencv

Output:
-I/usr/include/opencv -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab

Now we have all includes and libs.

So if you only need the libs just use --libs and copy the output to your .pro file. Your compiler will not link libs you don't use.

Offline

#3 2016-07-25 01:34:10

bokiscout
Member
Registered: 2015-09-27
Posts: 24

Re: [Solved] OpenCV and QT - search for libraries

xiouy wrote:

Your compiler will not link libs you don't use.

I was'n aware of this until now, nice ti hear from you.

Actually I'm already linking the whole output of 'pkg-config --libs opencv' to compile the project but I was thinking that this is not the right (best) way to do it.


What's the object-oriented way of becoming wealthy?
- Inheritance

Offline

Board footer

Powered by FluxBB