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:\.

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 panel → system → advanced system settings → advanced tab → environment variables...

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 file → new → project... → visual c++ → empty project. give name project (e.g: cvtest) , set project location (e.g: c:\projects).

click ok. visual c++ create empty project.

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

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

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

click ok close dialog.
back property dialog, select linker → input → additional 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).

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 add → new item... → visual c++ → c++ 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.

and first opencv program!
3. go here?
now opencv environment ready, what's next?
- go samples dir →
c:\opencv\samples\cpp. - read , compile code.
- write own code.
Comments
Post a Comment