Ask Your Question
0

VS2010 setting

asked 2014-05-09 08:53:51 -0600

updated 2014-05-09 10:49:34 -0600

berak gravatar image

Hello to all, I have a problem with the settings of visual studio 2010.

I followed step by step guide that I found on your website and trying the sample program I can compile without problems.

The fact is this: when I run the program, it gives me error as it finds the .dll libraries.

Guide on this step is not explained. Where and what should I include in Visual Studio? Could someone help me please?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2014-05-09 10:48:27 -0600

unxnut gravatar image

You should add the directory that contains DLLs into the system environment variable PATH. You will need to do that through the control panel on your machine.

edit flag offensive delete link more
1

answered 2014-05-09 11:36:30 -0600

FLY gravatar image

updated 2014-05-09 11:37:55 -0600

1. Installing OpenCV 2.4.3 you can change it according to your version

First, get OpenCV 2.4.3 from sourceforge.net. Its a self-extracting so just double click to start the installation. Install it in a directory, say C:\.

OpenCV self-extractor

Wait until all files get extracted. It will create a new directory C:\opencv which contains OpenCV header files, libraries, code samples, etc.

Now you need to add the directory C:\opencv\build\x86\vc10\bin to your system PATH. This directory contains OpenCV DLLs required for running your code.

Open Control PanelSystemAdvanced system settingsAdvanced Tab → Environment variables...

enter image description here

On the System Variables section, select Path (1), Edit (2), and type C:\opencv\build\x86\vc10\bin; (3), then click Ok.

On some computers, you may need to restart your computer for the system to recognize the environment path variables.

This will completes the OpenCV 2.4.3 installation on your computer.


2. Create a new project and set up Visual C++

Open Visual C++ and select FileNewProject...Visual C++Empty Project. Give a name for your project (e.g: cvtest) and set the project location (e.g: c:\projects).

New project dialog

Click Ok. Visual C++ will create an empty project.

VC++ empty project

Make sure that "Debug" is selected in the solution configuration combobox. Right-click cvtest and select PropertiesVC++ Directories.

Project property dialog

Select Include Directories to add a new entry and type C:\opencv\build\include.

Include directories dialog

Click Ok to close the dialog.

Back to the Property dialog, select Library Directories to add a new entry and type C:\opencv\build\x86\vc10\lib.

Library directories dialog

Click Ok to close the dialog.

Back to the property dialog, select LinkerInputAdditional Dependencies to add new entries. On the popup dialog, type the files below:

opencv_calib3d243d.lib
opencv_contrib243d.lib
opencv_core243d.lib
opencv_features2d243d.lib
opencv_flann243d.lib
opencv_gpu243d.lib
opencv_haartraining_engined.lib
opencv_highgui243d.lib
opencv_imgproc243d.lib
opencv_legacy243d.lib
opencv_ml243d.lib
opencv_nonfree243d.lib
opencv_objdetect243d.lib
opencv_photo243d.lib
opencv_stitching243d.lib
opencv_ts243d.lib
opencv_video243d.lib
opencv_videostab243d.lib

Note that the filenames end with "d" (for "debug").

enter image description here

Click Ok to close the dialog. Click Ok on the project properties dialog to save all settings.

NOTE:

These steps will configure Visual C++ for the "Debug" solution. For "Release" solution (optional), you need to repeat adding the OpenCV directories and in Additional Dependencies section, use:

opencv_core243.lib
opencv_imgproc243.lib
...

instead of:

opencv_core243d.lib
opencv_imgproc243d.lib
...

You've done setting up Visual C++, now is the time to write the real code. Right click your project and select AddNew Item...Visual C++C++ File.

Add new source file

Name your file (e.g: loadimg.cpp) and click Ok. Type the code below in the editor:

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

using namespace cv;
using namespace std;

int main()
{
    Mat im = imread("c:/full/path/to/lena.jpg");
    if (im.empty()) 
    {
        cout << "Cannot load image!" << endl;
        return -1;
    }
    imshow("Image", im);
    waitKey(0);
}

The code above will load c:\full\path\to\lena.jpg and display the image. You can use any image you like, just ... (more)

edit flag offensive delete link more

Comments

Please do upload your nice answer as an update of the current windows installation guide!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-09 14:55:17 -0600 )edit

@steven sorry, I don't know how to upload it

FLY gravatar imageFLY ( 2014-05-09 16:33:36 -0600 )edit
1

@FLY look here on guidelines for contributions. The guides themselves are written as rst files.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-10 07:24:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-09 08:53:51 -0600

Seen: 323 times

Last updated: May 09 '14