Installing OpenCV 2.4.3 in Visual C++ 2010 Express -


how install , use opencv 2.4.3 under vc++ 2010 express?

1. installing opencv 2.4.3

first, opencv 2.4.3 sourceforge.net. self-extracting double click start installation. install in directory, c:\.

opencv self-extractor

wait until files extracted. create new directory c:\opencv contains opencv header files, libraries, code samples, etc.

now need add directory c:\opencv\build\x86\vc10\bin system path. directory contains opencv dlls required running code.

open control panelsystemadvanced system settingsadvanced tab → environment variables...

enter image description here

on system variables section, select path (1), edit (2), , type c:\opencv\build\x86\vc10\bin; (3), click ok.

on computers, may need restart computer system recognize environment path variables.

this completes opencv 2.4.3 installation on computer.


2. create new project , set visual c++

open visual c++ , select filenewproject...visual c++empty project. give name project (e.g: cvtest) , set project location (e.g: c:\projects).

new project dialog

click ok. visual c++ create empty project.

vc++ empty project

make sure "debug" selected in solution configuration combobox. right-click cvtest , select propertiesvc++ directories.

project property dialog

select include directories add new entry , type c:\opencv\build\include.

include directories dialog

click ok close dialog.

back property dialog, select library directories add new entry , type c:\opencv\build\x86\vc10\lib.

library directories dialog

click ok close dialog.

back property dialog, select linkerinputadditional dependencies add new entries. on popup dialog, type 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 filenames end "d" (for "debug"). note if have installed version of opencv (say 2.4.9) these filenames end 249d instead of 243d (opencv_core249d.lib..etc).

enter image description here

click ok close dialog. click ok on project properties dialog save settings.

note:

these steps configure visual c++ "debug" solution. "release" solution (optional), need repeat adding opencv directories , in additional dependencies section, use:

opencv_core243.lib
opencv_imgproc243.lib
...

instead of:

opencv_core243d.lib
opencv_imgproc243d.lib
...

you've done setting visual c++, time write real code. right click project , select addnew item...visual c++c++ file.

add new source file

name file (e.g: loadimg.cpp) , click ok. type code below in 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 load c:\full\path\to\lena.jpg , display image. can use image like, make sure path image correct.

type f5 compile code, , display image in nice window.

first opencv program

and first opencv program!


3. go here?

now opencv environment ready, what's next?

  1. go samples dir → c:\opencv\samples\cpp.
  2. read , compile code.
  3. write own code.

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -