跳到主要內容

發表文章

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 th...

難捨

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

Opencv : 找輪廓並算面積

cvSmooth(imgMain,imgMain); cvCvtColor(imgMain,imgGray,CV_BGR2GRAY); cvCanny( imgGray, imgCanny, 50, 250); cvDilate(imgCanny,imgCanny); //合併小區域. cvThreshold(imgCanny,imgCanny,50.0,255,CV_THRESH_BINARY);//設定輪廓閾值 cvSaveImage("testImageA.bmp",imgMain); double area=0; CvMemStorage * storage = cvCreateMemStorage(0); CvSeq * contour = 0; int mode = CV_RETR_EXTERNAL; contour = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , storage); cvFindContours(imgCanny, storage, &contour, sizeof(CvContour), mode, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0)); cvDrawContours(imgDst, contour, CV_RGB(0,0,255), CV_RGB(255, 0, 0), 2, 2, 8, cvPoint(0,0)); // int area_num=0; for( CvSeq* c = contour; c != 0; c = c->h_next ) { area = cvContourArea(c); area=area; area_num++; stboxMessage->Items->Add(String::Format( "The area of patern : {0}", area )); }

Opencv : 找角落的點

//不太實用(?) 先保存下來 CvSize imgSize=cvGetSize(imgMain); imgDst=cvCreateImage(imgSize,32,1); IplImage* imgGray=cvCreateImage(imgSize,8,1); cvCornerHarris(imgMain,imgDst,3); double minVal,maxVal; cvMinMaxLoc(imgDst,&minVal,&maxVal); cvConvertScale(imgDst,imgGray,255/(maxVal-minVal)); cvSaveImage("testImage.bmp",imgGray);

Opencv : Visual Studio內加入OpenCV可能遇到的錯誤

安裝完 OpenCV 並在 Visual Studio 設定好環境變數之後 加入 #include "cv.h" #include "highgui.h" #include "cxcore.h" 可能遇到下列錯誤 1>c:\program files\opencv\cxcore\include\cxtypes.h(205) : error C3862: 'cvRound': cannot compile an unmanaged function with /clr:pure or /clr:safe 1> Inline native assembly not supported in managed code 1>c:\program files\opencv\cxcore\include\cxtypes.h(205) : error C3645: 'cvRound' : __clrcall cannot be used on functions compiled to native code 1>c:\program files\opencv\cv\include\cvcompat.h(784) : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss 1>Snake.cpp 1>c:\program files\opencv\cxcore\include\cxtypes.h(205) : error C3862: 'cvRound': cannot compile an unmanaged function with /clr:pure or /clr:safe 1> Inline native assembly not supported in managed code 1>c:\program f...

Opencv : Cannot find or open the PDB file???

工具 》 選項 》 偵錯 》 符號 接下來就是選擇 Microsoft ,然後確認,重新編寫一個程序,什麼也可以,看看是不是好了?你沒有發現編譯很慢 ? 看到此目錄下符號緩存了嗎?找到這個目錄拷貝出來,找個地方存放。接下來就是去掉 Microsoft 符號服務器,要是不去,每次都要從 Microsoft 下載很麻煩,已經緩存了,我們就可以利用好這些緩存,至此完美解決。

Opencv : 安裝

Vusial Stdio 2010 ( VC2010 )下安裝 OpenCV2.1 轉自: http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=10070&p=39565&hilit=visual+2010#p37694 本文主要來自 heyoup 的「 面對面教你如何在VS2010 下配置OPENCV2.1 」,只是稍作編輯,參考其他地方的資料改正些許重要錯誤和缺漏。 環境: windows 7+visual studio 2010+opencv 2.1 ,成功! xp 更應該能成功。耐心點,按下面的一步一步來,應該是沒什麼問題的,祝您好運啦! 1 、下載文件 OpenCV2.1 官方地址: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/OpenCV-2.1.0-win.zip/download 推薦本論壇地址: http://www.opencv.org.cn/download/OpenCV-2.1.0-win32-vs2008.exe CMAKE 2.8.1 http://www.cmake.org/files/v2.8/cmake-2.8.1-win32-86.exe INTELTBB3.0 http://www.threadingbuildingblocks.org/uploads/77/151/3.0/tbb30_20100406oss_win.zip 2 、首先安裝 CMAKE2.8.1 ,然後將 OpenCV2.1 安裝到你將要放置 OPENCV 的地方,接著,解壓 INTEL TBB 3.0, 比如將 OPENCV 和 TBB 都放在 D:\Program Files 裡面。並在 OpenCV 文件夾下創建子目錄 D:\Program Files\OpenCV2.1\vs2010 ,用於存放編譯結果。 檢查 D:\Program Files\OpenCV2.1\bin 和 D:\Intel TBB 3.0\bin\ia32\vc10 是否已經被加入到環境變量 ( 我的電腦 - 屬性 - 環境變量 )PATH ,如果沒有,請加入。加入後需要註銷當前 Windows 用戶(或重啟)後...