Professional Documents
Culture Documents
Hướng dẫn cài đặt OpenCV 2
Hướng dẫn cài đặt OpenCV 2
Ch Where is the source code cac bn tr vo th mc ci OpenCV2.0 khi ny. Ch Where to build the binaries cac bn tr vo mt th mc no y s ch solution c to ra. Nhn Configure v chn mt mi trng phat trin thich hp ( y mnh chn VS2008)
Trong khung ca s chn, cac bn chn nhng phn cn to ra ( y chng ta cn to th vin nn chn OPENCV_BUILD_3RDPARTY_LIBS Nhn Generate v CMake s t chy sinh ra file cho bn. M th mc ni file c to ra, m Solution ln bng VS2008.
Chn nhng project nh trn build. Nhn chut phi chn Build Selection. Ngi i cho xong
3. Build file lib v th vin ng - M vo th mc cha solution (nh ca mnh l E:\Laptrinh Softs\openCVlib) vo lib\Debug v lib\Release chep tt c file .lib vo th mc ci OpenCV\lib (ca mnh l C:\OpenCV2.0\lib). Ta c :
Vy l xong phn chep file .lib. Gi ta vo th mc E:\Laptrinh Softs\openCVlib vo bin\Debug v bin\Release s thy cac file .dll. Ta s chep chng vo nhng d n ca mnh sau. 4. Cu hnh VS2008 - Ta m VS2008, vo ToolOptionsProjects and SolutionsC++ Directories - Ch Show directories for chn Include files: To 2 directory mi dn ti th mc ci OpenCV2.0 (ca mnh l C:\OpenCV2.0) -
5. Cu hnh Project - To mt project bt u code. Project kiu Win32 Console Application ngn ng C++. Gi s project tn l LearnOpenCV2.0 - Nhn chut phi vo Project, chn Properties - Vo Configuration PropertiesLinkerInput - Chn th Configuration l debug, g vo Additional Dependencies l : cv.lib cvaux.lib cxcore.lib cxts.lib cvhaartraining.lib highgui.lib ml.lib opencv_ffmpeg.lib - Chn th Configuration l release, cng g tng t. - Nhn OK. - Vo th mc ca Solution ca project ny(LearnOpenCV2.0) bin. To 2 th mc l Debug v Release. - Chep tt c cac file .dll t E:\Laptrinh Softs\openCVlib\bin\Debug v E:\Laptrinh Softs\openCVlib\bin\Release vo ln lt 2 th mc mi to trn. - Trong source files, to mt file DisplayImageVideo.cpp v g vo nh sau :
#include <cv.h> #include <highgui.h> int main(int argc, char** argv) { //Load image into img IplImage* img = cvLoadImage("/images/dog.jpg"); //Create a window with name "Vidu coban" type autosize cvNamedWindow("Vidu coban", CV_WINDOW_AUTOSIZE); //Show the image into that window cvShowImage("Vidu coban", img); //Wait for a key pressed cvWaitKey(0); //Then release image and destroy window cvReleaseImage(&img);
Ch trong on code trn, ta phi c mt nh dog.jpg nm trong th mc images t ti th mc ca project ny. Nhn F5, nu kt qu nh di y tc l bn ci t v cu hnh thnh cng. Chuc mng.
Nu hin li thng bo thiu file .dll, bn m li solution do CMake to ra build ng project b thiu, sau chep file vo 2 th mc Debug v Release.