Ask Your Question

How to do a mask or how to transform found contours to filled circles?

asked 2015-07-28 01:30:31 -0500

mmt gravatar image

How to transform all the contours found in a frame to a filled circle?

Let me explain, my video has many small objects, and it is hard to detect using Mosse tracking, because my objects change its form. So I had an idea, change all the found contours to filled circles, it means, convert all this objects found on this image :,JGsJX2C to something like this :,JGsJX2C#1 .

I am using python.

edit retag flag offensive close merge delete


may i know what have you tried to do so?

Balaji R gravatar imageBalaji R ( 2015-07-28 01:59:30 -0500 )edit

have you tried fitellipse? Does it solve your problem?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-07-28 03:08:48 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-07-28 03:22:35 -0500

Once you have a series of contours, you can convert them to according circles by using

vector< vector<Point> > contours;
vector< Point2f > centers;
vector< float > radiuses;
for(size_t i =0; i<contours.size(); i++){
   Point2f center;
   float radius;
   minEnclosingCircle(contours[i], center, radius);
// Now you can draw each one of them by using the circle command

You are welcome!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-07-28 01:30:31 -0500

Seen: 733 times

Last updated: Jul 28 '15