[問題] 找出最大面積輪廓指針

看板C_and_CPP作者 (missing)時間13年前 (2011/05/05 03:05), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
以下是部分的程式碼: cvFindContours( Imgbw, storage, &contour, sizeof(CvContour),CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0)); for(;contour!=NULL; contour=contour->h_next) { contour_area_temp=fabs(cvContourArea(contour,CV_WHOLE_SEQ)); if(contour_area_temp>contour_area_max) { contour_area_max=contour_area_temp; area_max_contour=contour; } } cvDrawContours(pContourImg, area_max_contour,CV_RGB(255,0,0), CV_RGB(0,0,255),2, 2, 8, cvPoint(0,0)); 經過上面的程式,area_max_contour應該只會指向面積最大的那個輪廓吧? 可是我用cvDrawContours函數畫出來的輪廓卻包含了其它的輪廓, 也就是比較小的輪廓 這是為什麼呢 p.s area_max_contour和contour_area_max都有先初始化為零了 謝謝回答!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.184.242.112 ※ 編輯: cherrybomb 來自: 111.184.242.112 (05/05 03:08) ※ 編輯: cherrybomb 來自: 111.184.242.112 (05/05 03:10) ※ 編輯: cherrybomb 來自: 111.184.242.112 (05/05 03:30)

05/05 19:13, , 1F
DrawContours 的參數 maxLevel 設成 0
05/05 19:13, 1F
文章代碼(AID): #1DmQE9Xt (C_and_CPP)