How to use OPENCV 2.4.10 with QTCreator 3.4.1

asked 2015-08-03 05:25:24 -0600

franken gravatar image

updated 2015-08-04 19:09:43 -0600

HI all, i want to use opencv with qtcreator on ubutnu 14.04 , can you help me to do this .

i have followed this link http://rodrigoberriel.com/2014/11/usi... but i get an error in compilation : cannot find -lopencv_imgcodecs

update : by doing pkg-config --libs opencv i cant find something like /usr/local/lib/libopencv_imgcodecs.so

the output of pkg-config --libs opencv

/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so /usr/local/lib/libopencv_viz.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -ltbb -lrt -lpthread -lm -ldl

and pkg-config --cflags opencv is

-I/usr/local/include/opencv -I/usr/local/include The source file : image description

The project configuration file --------------------------------------------------------------------- image description

thanks a lot

edit retag flag offensive close merge delete

Comments

1

you have to build and install opencv, before you can use it for your qt project

berak gravatar imageberak ( 2015-08-03 07:07:44 -0600 )edit

@berak , yes i have done that and i am working fine with opencv in command line ... please see the output comment in the updated post

franken gravatar imagefranken ( 2015-08-03 07:42:24 -0600 )edit
1

if it finds /usr/local/lib/libopencv_contrib.so (or opencv_legacy), - that must be opencv2.4, not 3.0.

looks like you got conflicting opencv installs on your box

berak gravatar imageberak ( 2015-08-03 07:46:14 -0600 )edit
1

@berak oh yes sorry it's opencv 2.4.10

franken gravatar imagefranken ( 2015-08-03 08:01:39 -0600 )edit
1

again, opencv_imgcodecs is a 3.0 module, does not exist in 2.4

berak gravatar imageberak ( 2015-08-03 08:02:56 -0600 )edit

so what's the equivalent of opencv_imgcodecs in opencv 2.4.10 ?

franken gravatar imagefranken ( 2015-08-03 08:20:18 -0600 )edit
1

highgui, probably.

berak gravatar imageberak ( 2015-08-03 08:21:06 -0600 )edit

@berak i have deleted the libs and added LIBS += pkg-config opencv --libs to the .pro file project ... now the error disapeared but i get realloc(): invalid pointer if i put any instruction related to opencv

franken gravatar imagefranken ( 2015-08-03 08:40:36 -0600 )edit
2

remove what you have added and add the following:

unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += opencv

it should work. Otherwise, what you can do is to go on the project at the left column (Active Projects View) --> right click --> Add Library... --> System Package --> and at the Package field write opencv and that should be ;-)

theodore gravatar imagetheodore ( 2015-08-03 14:41:08 -0600 )edit

@theodore ok now i have added the 2 lines and tried by system package => the compilation worked if i don't have some manipulation in opencv like just cv::Mat frame; (the same thing previously mentionned) .... if i add smth like cv::VideoCapture cap(0); or cv::Mat test_image = cv::imread("elarbi.jpg"); or cv::namedWindow("Disp"); i got the same error and the msg The program has crashed (it's the same thing as previously ) => i'm wondering what could be the problem because i don't have any errors in the opencv headers that i have included in the main.cpp ..... thanks

franken gravatar imagefranken ( 2015-08-03 16:41:00 -0600 )edit