2014-12-01 3 views
0

약간의 문제가 있으며 도움이 필요합니다. 두 개의 원이있는 이미지가 있고 센터의 좌표를 가져 오려고합니다. 한 원에 나는 문제를 해결했습니다. 나는 두 번째 원을 얻으려고 뜨거운 것을 모른다. 어떤 아이디어? 여기 Opencv : 두 원형 센터의 좌표를 얻는 방법?

Mat canny_output; 
     vector<vector<Point>> contours; 
     vector<Vec4i> hierarchy; 

     Canny(BGRFilter,canny_output,100,200,3); 

     findContours(canny_output,contours,hierarchy,CV_RETR_TREE,CV_CHAIN_APPROX_SIMPLE,Point(0,0)); 

     vector<Moments> mu(contours.size()); 

     for (int i=0;i<contours.size();i++) 
     { 
      mu[i]=moments(contours[i],false); 
     } 

     vector<Point2f> mc(contours.size()); 

     for (int i=0;i<contours.size();i++) 
     { 
      mc[i]=Point2f(mu[i].m10/mu[i].m00,mu[i].m01/mu[i].m00); 
     } 



     Mat drawing = Mat::zeros(canny_output.size(), CV_8UC3); 

     for(int i = 0; i< contours.size(); i++) 
     { 
      Scalar color = Scalar(121, 100, 90); 
      drawContours(drawing, contours, i, color, 2, 8, hierarchy, 0, Point()); 
      circle(drawing, mc[i], 4, color, -1, 8, 0); 
     } 

은 바이너리 이미지 여기 Here os the binary image 윤곽과 이미지가에게 있습니다 :

여기 내 코드입니다. enter image description here

답변

0

무릎 서클이

minAreaRect 또는 내가 호우 원 감지와 그것을 해결했습니다