跳到主要內容

Opencv : Building the OpenCV 2.2 library using CMake

Building the OpenCV 2.2 library using CMake

1. Install CMake
2. Start the CMake GUI from Start menu
3. Select:
* Where is the source code: (the directory where CMakeLists.txt in OpenCV is stored), eg: "C:\Program Files\OpenCV2.2"
* Where to build the binaries: (the directory where the OpenCV library will be built), eg: "C:\Program Files\OpenCV2.2\build"
4. Press Configure and select Visual Studio 2008 or 2010 project.
5. Enter any parameters, like if you want to build Python bindings, documentation, shared libraries, use TBB, CUDA, Eigen2 libraries, etc. (Note that TBB, 64-bit and CUDA may still be under development and therefore buggy)
6. Repeat pressing Configure until no more red rows are highlighted.
7. When ready, press Generate.
8. Open the "build" directory, where you will find your VS2008 or VS2010 "sln" file.
9. Open the sln file in VS2008 or VS2010, and Built the Solution. This should compile the OpenCV 2.2 library into the build folder.

Building your own projects using OpenCV 2.2 in Visual Studio

After you have compiled the OpenCV 2.2 library using CMake, you should configure your Visual Studio projects to use OpenCV:

1. Create your new project for C++
2. Go to project properties
3. Go to VC++ Directories
4. Add 2 new Include Directories (it's the path where you installed OpenCV, include folder):
* C:\Program Files\OpenCV2.2\include
* C:\Program Files\OpenCV2.2\include\opencv
5. Add 1 new Library Directory (it's the path where you installed OpenCV, lib folder):
* C:\Program Files\OpenCV2.2\lib
6. Go to Linker in the left menu and select Input option
7. Add these entries on Additional Dependencies option:
* C:\Program Files\OpenCV2.2\lib\opencv_core220d.lib
* C:\Program Files\OpenCV2.2\lib\opencv_highgui220d.lib
* C:\Program Files\OpenCV2.2\lib\opencv_video220d.lib
* C:\Program Files\OpenCV2.2\lib\opencv_ml220d.lib
* C:\Program Files\OpenCV2.2\lib\opencv_legacy220d.lib
* C:\Program Files\OpenCV2.2\lib\opencv_imgproc220d.lib
8. Make the content of 'OpenCV_Helloworld.cpp' as such:
#include "cv.h"等,但是備註修改為 #include "opencv2/imgproc/imgproc.hpp"
ERROR C1083
Visual C++ >>include 目錄
C:\OpenCV2.2\include\opencv;C:\OpenCV2.2\vs2010\include\;

留言

這個網誌中的熱門文章

C 和 C++ 的 Callback

C Callback Function with C++ Class 轉載於: http://lak4cyut.blogspot.tw/2008/08/c-callback-function-with-class.html 由於 C/C++ 語言的特性,許多 API 是必需要利用 Callback function 才能完成作用 在 C 的時代這是很合理也很直覺化的設計,但若將場景拉到 C++ 呢.... --此篇除了介紹 How 之外,也將對 Why 進行簡單的介紹,希望能夠令不知其所以然的人有所幫助。-- Effective C++m 一書將 C++ 視為一種語言聯邦,而其中最簡單及常被討論到的,我想大概是屬於 OOP 的部份。 在 C++ 中利用 Class 來實現 OO 的許多精神,許多的程式設計都會採用 OO 的封裝特性,也因此當你需要使用某些 API 時,會面臨到 callback function 設計不易的問題。包括如何取用物件內的屬性、如何將物件傳入等問題,假設利用 non-member function 來設計 callback function,為了能令 callback function 順利的存取相關的物件內的資料,可能會在某種程度上破壞掉物件的封裝性。 因此,若以封裝性的角度來看,我們當然會希望能夠直覺的以 class member function 來做為 callback function,如此一來,便可以在不破壞封裝性的情況下,依然順利的使用物件內的屬性。 在這個前提下,便會很直覺的寫出以下的程式段: class CMyClass { public: void Mainfunc() ; void CBfunc(void *) ; private: int iData ; int iInc ; } int CMyClass::CBfunc(void *iIncLoc) { int _i = (int)iIncLoc ; return iData+_i ; } void CMyClass::Mainfunc() { // APIfunc( *pCallback, *pParam) <-- br=""> APIfunc(CBfunc, i

c++(/clr)非託管類型和託管類型互轉

c++(/clr)非託管類型和託管類型互轉 轉載於: http://www.cnblogs.com/kekec/archive/2011/03/25.html 以下代碼必須有「Common Language Runtime Support(/clr)」 和「MFC」支持 1. 字符竄之間的轉換 1 // 託管類型到非託管類型 2 inline CString ManageToUnManageStr(System::String^ cmStr) 3 { 4 using namespace System::Runtime::InteropServices; 5 CString cStr = (char*)(Marshal::StringToHGlobalAnsi(cmStr)).ToPointer(); 6 return cStr; 7 } 8 9 // 非託管類型到託管類型 10 inline System::String^ UnManageToManageStr(const CString& cStr) 11 { 12 const char* cc = (LPCTSTR)cStr; 13 System::String^ cmStr = gcnew System::String(cc); 14 return cmStr; 15 } 2. 對象之間的轉換 1 // _variant_t到Object對象 2 inline System::Object^ VarToObject(_variant_t var) 3 { 4 using namespace System::Runtime::InteropServices; 5 System::IntPtr^ pvar = gcnew System::IntPtr(&var); 6 System::Object^ obj = Marshal::GetObjectForNativeVariant(*pvar); 7 return obj; 8 } 9 10 // Object對象到_variant_t 11 inline _variant_t* ObjectToVar(System::Object^ obj) 12 { 13 using namespace

難捨

每次星期天要和你道別的時候,心中總是有很多不捨。 只能告訴自己,很快的又能見面了。 在擁擠的火車上,思念還是停留在妳的身上。 那時深深的覺得,有一個能夠去呵護而值得愛的人,是一種幸福。