Solved

OpenCV, contours and circles

Posted on 2010-11-30
3
2,116 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
ID: 34250482
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
ID: 34281613
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
ID: 34324291
ok
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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