close

開啟新專案

專案名稱: VS2012ConsoleOpenCV248

image

按下<Next>按鈕

image

點選Console Application後, 按下<Finish>按鈕

image

Click <Property Mananger> tab, and focus on Release|Win32, click mouse's right button

image

Add New Property Sheet

image

設定屬性管理專案名稱例如OpenCV248VS2012以及儲存路徑(Location),按下<Add>按鈕

image

滑鼠雙擊開啟專案屬性管理:OpenCV248VS2012

image

C/C++ –> Additional Include Directories-> Edit

image

加入

C:\OpenCV-2.4.8\opencv\build\include\

C:\OpenCV-2.4.8\opencv\build\include\opencv

image

設定其他程式庫目錄

image

加入

C:\OpenCV-2.4.8\opencv\build\x64\vc11\lib

image

滑鼠點選<Input>, 接著點擊Additional Dependencies下拉選單, 選擇<Edit>

image

加入下列全部*.lib

opencv_calib3d248.lib
opencv_contrib248.lib
opencv_core248.lib
opencv_features2d248.lib
opencv_flann248.lib
opencv_gpu248.lib
opencv_highgui248.lib
opencv_imgproc248.lib
opencv_legacy248.lib
opencv_ml248.lib
opencv_nonfree248.lib
opencv_objdetect248.lib
opencv_ocl248.lib
opencv_photo248.lib
opencv_stitching248.lib
opencv_superres248.lib
opencv_ts248.lib
opencv_video248.lib
opencv_videostab248.lib

image

按下<Local Windows Debugger>發生錯誤訊息!!!

Cannot open include file ‘opencv2\core\core.hpp’

怎麼會這樣呢? 編輯程式還會即時自動跳出提示字, 怎麼編譯反而找不到?

image

解決方式:不曉得為什麼先前定義的Property Mananger未能發揮作用,

乾脆直接手動定義include & library路徑在VS2012ConsoleOpenCV248專案內

image

編譯錯誤解決了, 不過執行階段發生找不到opencv_core248.dll

image

請新增系統環境變數, 滑鼠點選<環境變數>

image

找尋Path, 加入

C:\OpenCV-2.4.8\opencv\build\x64\vc11\bin

image

測試OpenCV2.4.8

   1: #include "stdafx.h"
   2: #include <opencv2\core\core.hpp>
   3: #include <opencv2\highgui\highgui.hpp>
   4: #include <iostream>
   5: int _tmain(int argc, _TCHAR* argv[])
   6: {
   7:     cv::Mat img = cv::imread("sample.jpg");
   8:     cv::namedWindow("sample image");
   9:     cv::imshow("sample image", img);
  10:     cv::waitKey(0);
  11:     return 0;
  12: }

執行結果

image

範例程式: VS2012ConsoleOpenCV248

操作展示:2014 01 06 VS2012ConsoleOpenCV248

2013/01/06 今天重新再製作一次本範例, 發現要先更改專案屬性x64, 再載入property manager才會編譯OK,

先前遇到的問題, 應該是順序顛倒:先載入property manager再設定X64導致編譯錯誤

image

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(1) 人氣()