Ask Your Question
1

Cannot get opencv 3.0 to work

asked 2015-08-24 16:19:01 -0600

Y.S gravatar image

updated 2015-08-25 02:25:38 -0600

theodore gravatar image

Hi, I have a fatal unresolved external error when I'm trying to compile programs in opencv 3.0.0. Now I know that this question was asked many times but my problem is specific.

  • I installed opencv 3.0.0 in the "C:\" directory.
  • I created an empty project in Visual Studio 2012 (win32 console application).
  • I entered into the properties of the project's solution, and added the directory "C:\opencv\build\include" in "Additional Include Directories".
  • In the Linker, I added the directory "C:\opencv\build\x64\vc12\lib" in "Additional Library Directories" (I'm working with a 64-bit operating system). Then I added the files "opencv_ts300d.lib" and "opencv_world300d.lib" in "Additional Dependencies" (I'm working only in debug mode).

As far as I know these are the steps needed in order to run programs in opencv 3.0.0. But when I wrote the following code

include "opencv2\core\core.hpp"

include "opencv2\highgui\highgui.hpp"

using namespace cv;

void main()

{

    Mat img = imread("C:/BlackWhite.jpg", CV_LOAD_IMAGE_UNCHANGED);
    getchar();

}

I get an unresolved external for the function "imread". Why is that? Please I will be grateful for any answer I can get. Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-08-26 10:15:59 -0600

In OpenCV 2.4.x, cv::imread was provided in highgui module.
But, this function moved to imgcodecs module from OpenCV 3.0.

So, you need to include "opencv2\imgcodecs\imgcodecs.hpp" and
link opencv_imgcodecs300d.lib to use this function.

edit flag offensive delete link more

Comments

you're right about the changes, but the weird thing is:the prebuilt opencv_world300.lib should contain all of those modules

berak gravatar imageberak ( 2015-08-26 10:26:14 -0600 )edit
1

Sorry, I was overlooking opencv_world300d.lib.
I found the following point.

[Library path]

Compiler: Visual Studio 2012
Library path: C:\opencv\build\x64\vc12\lib

I think that you need to set C:\opencv\build\x64\vc11\lib for Visual Studio 2012(VC11).

[Solution platform]

I created an empty project in Visual Studio 2012 (win32 console application).

I think that you need to change Solution platform from Win32 to x64.

dandelion1124 gravatar imagedandelion1124 ( 2015-08-26 10:43:35 -0600 )edit

Thanks for the answers! It seems that indeed VC12 is destined to work only with visual studio 2013, so I changed the path to VC11. Also, as suggested, I had to change, in the configuration manager, the target platform to be x64 instead of win32.

After that I found out that the program cannot be executed in debug mode (since as I understand, the debug mode at this time is not distributable...?) So I had to do anything that was suggested but in release mode and then it finally worked. Thanks!

Y.S gravatar imageY.S ( 2015-08-26 15:36:15 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-08-24 16:19:01 -0600

Seen: 617 times

Last updated: Aug 26 '15