Ask Your Question
-3

Color Blob Detection With Rectangle

asked Aug 12 '13

AndyStevens gravatar image

updated Aug 16 '13

Can anyone help me to understand this?

public static int getBiggestContourIndex(List<MatOfPoint> contours){
double maxArea = 0;
Iterator<MatOfPoint> each = contours.iterator();
int j = 0;
int k = -1;
while (each.hasNext())
{
MatOfPoint wrapper = each.next();
double area = Imgproc.contourArea(wrapper);
if (area > maxArea){
maxArea = area;
k = j;
}
j++;
}
return k;
}
Preview: (hide)

Comments

2

oh dear, can't read your own code ?

berak gravatar imageberak (Aug 12 '13)edit
1

probably just a copy paste ;)

StevenPuttemans gravatar imageStevenPuttemans (Aug 12 '13)edit
1

Can you explain why you keep editing the question if it is already solved?

StevenPuttemans gravatar imageStevenPuttemans (Aug 16 '13)edit

1 answer

Sort by » oldest newest most voted
1

answered Aug 12 '13

Basically like @berak suggested you not reading your code. The following line selects the largest blob.

int k = getBiggestContourIndex(contours);

If yoy want to detect all blobs, get amount of elements from contour vector, then iterate over it using a for loop and do processing for each blob in the loop.

Preview: (hide)

Comments

Do you mean, i should make a new "get center point" with different point?

AndyStevens gravatar imageAndyStevens (Aug 14 '13)edit

You can get the amount of elements of the contour vector by using it size property. Then do a for loop and visualize each blob with the same code like above. If you do not understand it, then it isn't a problem of computer vision, but about not understanding the basics of C++ programming.

StevenPuttemans gravatar imageStevenPuttemans (Aug 14 '13)edit

thank you, i'm trying :)

AndyStevens gravatar imageAndyStevens (Aug 14 '13)edit

Question Tools

Stats

Asked: Aug 12 '13

Seen: 2,011 times

Last updated: Aug 16 '13