Solved

OpenCV, contours and circles

Posted on 2010-11-30
3
2,150 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Triangles - Calculating angles 7 80
C++ :Change value from  DisableCMD registry 4 80
Math equations 13 74
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 96
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…
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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…

739 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