MSER circles center -
i`m using mser feature detector detect circles image , works perfect have center of circles. know posibility center? here source code:
void main() { mat inimg = imread(cprofilessuro1012desktop1.bmp); mat textimg; cvtcolor(inimg, textimg, cv_bgr2gray); vector vector point contours; vector rect bboxes; ptr mser mser = msercreate(22, (int)(0.00001textimg.colstextimg.rows), (int)(0.00015textimg.colstextimg.rows), 1, 1); mser-detectregions(textimg, contours, bboxes); for(int i=0;i1;i++) { for(int j=0;jcontours[i].size();j++) cout x=contours[i][j].x y=contours[i][j].y endl; coutendl; } (int = 0; bboxes.size(); i++) { cout x=bboxes[i].x y=bboxes[i].y endl; rectangle(inimg, bboxes[i], cv_rgb(0, 255, 0)); } cout contours[0].size()endl; imshow(, inimg); waitkey(0); }
what did:
float sumx = 0, sumy = 0; int size = contours.size(); point2f centroid; if(size > 0){ for(int i=0;i<size;i++) { for(int j=0;j<contours[i].size();j++) { sumx += contours[i][j].x; sumy += contours[i][j].y; } centroid.x = sumx/contours[i].size(); centroid.y = sumy/contours[i].size(); cout<<centroid.x<<" " <<centroid.y<<endl; sumx=0; sumy=0; }
Comments
Post a Comment