cmmlin2016.files.wordpress.com · web viewimage = imread("happyman's girl.jpg",...

9
OpenCV 安安安安

Upload: lyque

Post on 20-Jun-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

OpenCV 安裝教學

Page 2: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

下載 opencv

安裝 opencv 到 C:\下

安裝中

Page 3: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

到我的電腦,右鍵內容,進階系統設定,環境變數

在環境變數 path 裡,將下面參數,複製貼到[環境變數]-[Path]-[變數值]最後面;C:\opencv\build;C:\opencv\build\x86\vc10\bin

Page 4: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

新增專案

確定後,選擇空專案

Page 5: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

點選 專案,屬性

專案->屬性->VC++目錄,將下面參數,複製貼到其目錄最後面Include 目錄:;C:\opencv\build\include;C:\opencv\build\include\opencv

程式庫目錄:;C:\opencv\build\x86\vc10\lib

Page 6: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

點選 專案->屬性->連結器->輸入,將下面參數,複製貼到最後面其他相依性:;opencv_core246d.lib;opencv_calib3d246d.lib;opencv_contrib246d.lib;opencv_features2d246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib

建立 cpp 檔

建立 cpp 檔

Page 7: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

測試範例程式碼看是否安裝成功#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <iostream>using namespace cv;using namespace std; int main( int argc, char** argv ){ Mat image; if( argc != 2){ cout <<" Usage: display_image ImageToLoadAndDisplay" << endl; image = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file } else{ image = imread(argv[1], CV_LOAD_IMAGE_COLOR); } if(! image.data ){// Check for invalid input cout << "Could not open or find the image" << endl ; system("pause"); return -1; } namedWindow( "HappyMan - Display window", CV_WINDOW_AUTOSIZE ); // Create a window for display. imshow( "HappyMan - Display window", image ); // Show our image inside it. waitKey(0); // Wait for a keystroke in the window return 0;}

Page 8: cmmlin2016.files.wordpress.com · Web viewimage = imread("HappyMan's Girl.jpg", CV_LOAD_IMAGE_COLOR); //put the image into Stall_Test package // Read the file} else{image = imread(argv[1],

測試範例程式碼看是否安裝成功

顯示圖片