Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OpenCV, contours and circles

Posted on 2010-11-30
3
Medium Priority
?
2,236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

730 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