Ask Your Question
1

OpenCV with QT cv::imread problem.

asked 2015-06-11 02:07:54 -0600

MarcinXY gravatar image

Dear QT an OpenCV users,

I have installed with CMake actual OpenCV 3.0.0 on my machine. I'm using QT Creator 5.3 with MinGW 32bit (my OS is Win7 64bit).

This simple example code is successfully compiled:

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(int argc, char *argv[])
{
namedWindow("Output",1);
Mat output = Mat::zeros(120,350,CV_8UC3);
putText(output,"Hello World :)", cvPoint(15,70),FONT_HERSHEY_PLAIN,3, cvScalar(0,255,0),4);
imshow("Output",output);
waitKey(0);
return 0;
}

It works! So my .pro file, headers, libs, patch etc. should be ok...

But when I try to use something my own, by adding just one line to this code like this:

Mat src = imread("C:/test.bmp",1);

I get the following error during compilation:

undefined reference to `cv::imread(cv::String const&, int)'

I don't really know what I'm doing wrong :( I have been searching in google etc. People have this issue but they have undefined references with all cv:: functions. I can't understand what is wrong there if my example code works (cv::imshow etc. are works).

Those libs in my .pro file are not enought? Please, have a look:

INCLUDEPATH += E://OpenCV//release//install//include
LIBS += "E:\OpenCV\release\lib\libopencv_core300.dll.a"
LIBS += "E:\OpenCV\release\lib\libopencv_highgui300.dll.a"
LIBS += "E:\OpenCV\release\lib\libopencv_imgproc300.dll.a"
LIBS += "E:\OpenCV\release\lib\libopencv_features2d300.dll.a"
LIBS += "E:\OpenCV\release\lib\libopencv_calib3d300.dll.a"

Thanks a lot in advance for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2015-06-11 02:11:55 -0600

berak gravatar image

updated 2015-06-11 11:35:14 -0600

some modules have changed in 3.0. to use imread()/imwrite(), add:

LIBS += "E:\OpenCV\release\lib\libopencv_imgcodecs300.dll.a"

for VideoCapture, VideoWriter (also previously in highgui), add:

LIBS += "E:\OpenCV\release\lib\libopencv_videoio300.dll.a"
edit flag offensive delete link more

Comments

1

Yes! This is it! Thank You mr berak. You are a life saver!

MarcinXY gravatar imageMarcinXY ( 2015-06-11 04:12:44 -0600 )edit
1

also keep an eye on the transition guide

berak gravatar imageberak ( 2015-06-11 04:27:21 -0600 )edit
2

And btw, once you included #include <opencv2/opencv.hpp> you automatically have all the necessary headers. So you do not need other includes in code anymore! Like @berak said it is purely a linking error.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-11 07:56:03 -0600 )edit
2

I will remember that. Thank You for helpful hints!

MarcinXY gravatar imageMarcinXY ( 2015-06-11 10:19:02 -0600 )edit

Thanks ! This answer helped me..

munibfazal gravatar imagemunibfazal ( 2016-02-24 05:15:57 -0600 )edit

Thanks!! This fixed my issue.

Daniel K gravatar imageDaniel K ( 2016-04-21 14:57:24 -0600 )edit

How is this can be fixed in Ubuntu? I am new to OpenCV :(

MenukaIshan gravatar imageMenukaIshan ( 2018-06-16 06:13:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-11 02:07:54 -0600

Seen: 7,239 times

Last updated: Jun 11 '15