Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OpenCV, contours and circles

Posted on 2010-11-30
3
Medium Priority
?
2,257 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures 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.
Suggested Courses

916 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