跳到主要內容

發表文章

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 下載很麻煩,已經緩存了,我們就可以利用好這些緩存,至此完美解決。