Solved

OpenCV, contours and circles

Posted on 2010-11-30
3
2,073 Views
Last Modified: 2012-05-10
Hello experts!

Just for curiosity and to learn something new I am using contours to find circles in image.

This is my approach.

1. First I find edges by:

cvThreshold( img_8uc1, img_edge, thresh, 255, CV_THRESH_BINARY );    

where thresh changes from 200 down to 20.

I repeat the whole procedure for every value of thresh


2. I look for contours:

cvFindContours( img_edge, storage, (CvSeq**)&chain, sizeof(CvChain), CV_RETR_LIST, CV_CHAIN_CODE );

3. Then I accumulate Freeman chain codes by their values.

For circles I expect to get similiar amounts for Freeman directions:

0 and 2 and 4 and 6
1 and 3 and 5 and 7

and it works fine in most cases.
Problem is that for some contour shapes it doesn't.

So the question is:

How can I find circles by analysing contours using OpenCV?

Thank you :-)

panJames



0
Comment
Question by:panJames
  • 2
3 Comments
 
LVL 17

Expert Comment

by:CSecurity
Comment Utility
your question is a something that you should do it. you know, because it's all mathematics. Once, I decided to code a captcha reader using openCV in C++. I had to find a algorithm but google in these cases are useless. I picked up a pencil and a lot of paper, then started to think about mathematical algorithms. finally found a algorithm and my captcha reader worked. so, do what I did.
Regards
0
 

Accepted Solution

by:
panJames earned 0 total points
Comment Utility
The way I solved the problem:

I found center of the circle surrounding contour.

I checked how many contour points are at the radius distance from the center.

If more then 80% then it is a circle.

panJames
0
 

Author Closing Comment

by:panJames
Comment Utility
ok
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A Guide to the PMT, FV, IPMT and PPMT Functions In MS Excel we have the PMT, FV, IPMT and PPMT functions, which do a fantastic job for interest rate calculations.  But what if you don't have Excel ? This article is for programmers looking to re…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now