1

I have a problem in opencv function. I can use

IplImage* img = CvLoadImage("2_DeepViewOutput.png");

However I cannot use

Mat img = imread("2_DeepViewOutput.png");

It gave me

Multiple markers at this line - Line breakpoint: Hello.cpp [line: 11] - undefined reference to `cv::imread(std::string const&, int)'

I think I have loaded the library in the path. I did not know the reason, please help me.

user2727765
  • 616
  • 1
  • 12
  • 28
user2529307
  • 25
  • 1
  • 4
  • Windows? Compiler clearly says you have not linked with the proper lib (probably opencv2's `highgui`). – Cfr Aug 29 '13 at 14:48
  • possible duplicates: [1](http://stackoverflow.com/questions/12770115/linking-libraries-opencv-2-4-2-on-xcode-4-5-1), [2](http://stackoverflow.com/questions/2584273/issue-with-reading-an-image-using-cvimread-function-in-opencv) – Cfr Aug 29 '13 at 14:49

2 Answers2

1

The problem is that you have included C header files, not C++ header files. So, your program cannot be compiled because the declaration of the cv::imread(std::string const&, int) function is not present in the C header file.

So, you have to include C++ header files. (e.g - #include "opencv2/highgui/highgui.hpp") (This link will help you)

And if you have not configured your IDE for C++, please go through this link

SRF
  • 929
  • 1
  • 7
  • 15
0

The problem is with the missing dll in your IDE path. Following this link step by step will solve your issue.

user2727765
  • 616
  • 1
  • 12
  • 28
  • I think I am right in IDE path, if I was wrong, how can I run the function CVLoadImage ? Is it C++ function can not run? C is OK? – user2529307 Aug 29 '13 at 16:32
  • No,I using elcipse, opencv 2.4.5. Now, I have to programming by C, because I cannot use C++ function in opencv. Like I can use CvLoadImage to load an image, I cannot use imread directly. – user2529307 Aug 30 '13 at 16:54
  • No there is something wrong, can you try with Netbeans? ITs pretty straight forward. – user2727765 Aug 31 '13 at 03:59
  • I am familiar with eclipse... I still have no idea on that. – user2529307 Sep 11 '13 at 16:16