Problem with configuration in VS2015 Opencv 3.1.0

asked 2016-03-19 22:25:40 -0500

Nisal gravatar image

updated 2016-03-19 22:27:12 -0500

Since I'm new to the Opencv i followed a tutorials to install.

  1. First I downloaded Opencv 3.1.0 from http://opencv.org.
  2. Then I extract in to C drive.
  3. And set environment variables. Add a new variable OPENCV_DIR and set value to C:\opencv\build\x64\vc14 and set the path to %OPENCV_DIR%\bin.
  4. Then I open new project in C++ Console Application and set properties,

Release >

C/C++ General > Additional Include Directories --> $(OPENCV_DIR)....\include.

Linker General > Additional Include Directories -->$(OPENCV_DIR)\lib

Linker Input> Additional Dependancies-->opencv_world310.lib

Debug >

C/C++ General > Additional Include Directories --> $(OPENCV_DIR)....\include.

Linker General > Additional Include Directories -->$(OPENCV_DIR)\lib

Linker Input> Additional Dependancies-->opencv_world310d.lib

Then I used a test code..

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)

{
    Mat img = imread("C:\\Users\\Nisal\\Desktop\\b.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
    cout << "Error : Image cannot be loaded..!!" << endl;
    //system("pause"); //wait for a key press
    return -1;
}

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

waitKey(0); //wait infinite time for a keypress

destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

return 0;
}

there are no build errors. When i run, a windows console opens and close suddenly, the picture i want to display is not displaying. Output is like this..says some missing PDB files. So what should I do to make this correct. image description

edit retag flag offensive close merge delete

Comments

Have you copied the opencv_world310.dll to the application folder? PDB file contains debugging information and is not needed for running the program. And for OpenCV 3.1 it is

#include <opencv2/highgui.hpp>

But for this program more than just highui.hpp is missing you should use

#include <opencv2/opencv.hpp>
matman gravatar imagematman ( 2016-03-20 04:04:33 -0500 )edit

No I didn't copy the dll file to application folder. Where should I copy the dll file.?

Nisal gravatar imageNisal ( 2016-03-20 09:49:41 -0500 )edit

In that folder where your .exe file is. But usually the program crashes if a dll is missing :-\

matman gravatar imagematman ( 2016-03-20 13:38:03 -0500 )edit