Install OpenCV 2.4.3 (see OpenCV 2.4.3 Installation)
สร้างโปรเจคใหม่ (ตาม วิธีการสร้างโปรเจคใหม่ใน Visual C++ 2010)
Create new project (see How to Create New Project in Visual C++ 2010)
ไปที่ Project แล้วเลือก Properties...
Go to Project then select Properties...
Property Pages is shown as below
Go to Configuration Properties then select VC++ Directories
เพิ่ม C:\OpenCV2.4.3\build\include ในช่อง Include Directories และเพิ่ม C:\OpenCV2.4.3\build\x86\vc10\lib ในช่อง Library Directories
Add C:\OpenCV2.4.3\build\include in Include Directories and add C:\OpenCV2.4.3\build\x86\vc10\lib in Library Directories
ไปที่ Linker แล้วเลือก InputAdd C:\OpenCV2.4.3\build\include in Include Directories and add C:\OpenCV2.4.3\build\x86\vc10\lib in Library Directories
Go to Linker then select Input
เพิ่ม opencv_core243.lib;opencv_highgui243.lib;opencv_imgproc243.lib;opencv_features2d243.lib;opencv_flann243.lib;opencv_gpu243.lib;opencv_haartraining_engine.lib;opencv_legacy243.lib;opencv_ml243.lib;opencv_objdetect243.lib;opencv_ts243.lib;opencv_video243.lib;opencv_calib3d243.lib;opencv_contrib243.lib; ในช่อง Additional Dependencies แล้วกดปุ่ม OK
Add opencv_core243.lib;opencv_highgui243.lib;opencv_imgproc243.lib;opencv_features2d243.lib;opencv_flann243.lib;opencv_gpu243.lib;opencv_haartraining_engine.lib;opencv_legacy243.lib;opencv_ml243.lib;opencv_objdetect243.lib;opencv_ts243.lib;opencv_video243.lib;opencv_calib3d243.lib;opencv_contrib243.lib; in Additional Dependencies then press OK
Add opencv_core243.lib;opencv_highgui243.lib;opencv_imgproc243.lib;opencv_features2d243.lib;opencv_flann243.lib;opencv_gpu243.lib;opencv_haartraining_engine.lib;opencv_legacy243.lib;opencv_ml243.lib;opencv_objdetect243.lib;opencv_ts243.lib;opencv_video243.lib;opencv_calib3d243.lib;opencv_contrib243.lib; in Additional Dependencies then press OK
ใส่โค้ดตามด้านล่าง โดยเปลี่ยนจาก C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg เป็นตำแหน่งของรูปภาพในเครื่องของคุณ
Insert code as below by changing C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg to your image path
Insert code as below by changing C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg to your image path
- #include "stdafx.h"
- #include<opencv\cv.h>
- #include<opencv\highgui.h>
- int _tmain(int argc, _TCHAR* argv[])
- {
- IplImage* img=cvLoadImage("C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg",1);
- cvNamedWindow("image");
- cvShowImage("image",img);
- cvWaitKey();
- return 0;
- }
กดปุ่ม F5 บนคีย์บอร์ดเพื่อเริ่มรันโปรแกรม ซึ่งผลลัพธ์จะเป็นตามภาพด้านล่าง
Press F5 on keyboard to start debugging which the result is shown as below
Press F5 on keyboard to start debugging which the result is shown as below
No comments:
Post a Comment