Ask Your Question
-3

Color Blob Detection With Rectangle

asked 2013-08-12 11:05:24 -0600

AndyStevens gravatar image

updated 2013-08-16 09:14:22 -0600

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;
}
edit retag flag offensive close merge delete

Comments

2

oh dear, can't read your own code ?

berak gravatar imageberak ( 2013-08-12 12:17:43 -0600 )edit
1

probably just a copy paste ;)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-12 14:10:25 -0600 )edit
1

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

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-16 09:54:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-08-12 14:12:08 -0600

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.

edit flag offensive delete link more

Comments

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

AndyStevens gravatar imageAndyStevens ( 2013-08-14 03:03:39 -0600 )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 ( 2013-08-14 03:12:45 -0600 )edit

thank you, i'm trying :)

AndyStevens gravatar imageAndyStevens ( 2013-08-14 03:23:19 -0600 )edit

Question Tools

Stats

Asked: 2013-08-12 11:05:24 -0600

Seen: 1,886 times

Last updated: Aug 16 '13