How to use OPENCV 2.4.10 with QTCreator 3.4.1

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

franken gravatar image

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

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 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/

the output of pkg-config --libs opencv

/usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/libopencv_ts.a /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ -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



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 -0500 )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 -0500 )edit

if it finds /usr/local/lib/ (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 -0500 )edit

@berak oh yes sorry it's opencv 2.4.10

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

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

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

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

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

highgui, probably.

berak gravatar imageberak ( 2015-08-03 08:21:06 -0500 )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 -0500 )edit

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 -0500 )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 -0500 )edit