[問題] opencv Canny檢測

看板C_and_CPP作者 (愛世代)時間13年前 (2011/03/01 16:11), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) DEV C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) opencv2.0 問題(Question): 我有個2問題想請教, 首先我這次是練習書上的例題,程式編譯ok 可是只秀出原圖? 第二以docanny語法來說 void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 ); 我看過其他人寫最後一項是用double宣告。書上也是用這宣告。 可是就我的情況要用int宣告才ok,這是怎麼了??? 餵入的資料(Input): lena.jpg 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) #include <stdlib.h> #include <cv.h> #include <highgui.h> using namespace cv; IplImage *doCanny(IplImage * in,double lowThresh,double highThresh,int aperture) { if(in->nChannels !=1) return(0);//Canny only handles gray scale images IplImage * out=cvCreateImage(cvGetSize(in),IPL_DEPTH_8U,1); cvCanny( in, out,lowThresh,highThresh,aperture); return out; cvShowImage("After Canny detect",out); }; int main() { cvNamedWindow("orgin_image-in"); cvNamedWindow("After Canny detect"); IplImage *in= cvLoadImage("lena.jpg"); cvShowImage("orgin_image-in",in); doCanny( in,50,150,3); //wait for the user to hit a key ,then clean up the window cvWaitKey(0); cvDestroyWindow("orgin_image-in"); cvDestroyWindow("After Canny detect"); return 0; } 補充說明(Supplement): 請大家賜教^^ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 我查到解決方法了 我將這行 IplImage *in= cvLoadImage("lena_gray.jpg"); 改為 IplImage *in= cvLoadImage("lena_gray.jpg",0); 我在OPENCV中文討論區查到的,可是不太了解為何可以這樣改 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.118.21.111 ※ 編輯: vincent59 來自: 140.118.21.111 (03/01 18:09) ※ 編輯: vincent59 來自: 140.118.21.111 (03/01 18:50)

03/02 11:06, , 1F
cvLoadImage("Filename", "灰階或彩色");
03/02 11:06, 1F

03/02 12:30, , 2F
謝謝你
03/02 12:30, 2F
文章代碼(AID): #1DRAeQ7k (C_and_CPP)