Circle recognition using openCV

The picture below demonstrats openCV recognition progress of object detection. In this step, we now can locate the circle shapes in the captured image and output the number of the circles found.

circlerecg

Source code : circleDetect.cpp if you need more instructions please leave your comments.

Author: Andol Li

A HCI researcher, a digital media lecturer, an information product designer, and a python/php/java coder.

106 Comments On “ Circle recognition using openCV”

  1. can u please send me the code to detect circles in an image using OpenCV.. I need to detect a yellow ball in a image.
    My email address:brkapadia2003@yahoo.com

  2. Hey Andol,
    i have to detect balls (they are all the same size) on a picture. I used cvSub and cvHoughCircles, and find all balls on the picture. But openCV doesn’t find them centered… so I’d like to test your code and see if it works better.
    So please could you send me your code?
    fightmaster[at]mkh-clan.de

    Thank you!

  3. can u please send me the code to detect circles in an image using OpenCV.. I need to detect a Orange ball in a image.
    My email address:frndsndrahul@gmail.com

  4. Thank you very much man, I will test your code (if it is the one I found in your link). One question here. I used to use Camshift to find green object(a green ball in another colored background), but it seems that my webcam doesnt do well find that. Do you think you algorithm will be better finding it? I will leave you feedback when I tested your program.

    Thank you again

      • Hi Andol,
        Thanks a loooot for your reply.
        I tested the code but :
        int px[0], py[0];
        gives me a problem. I use VS 2005 to compile it and it and the errors are :
        cvtest.cpp(61) : error C2466: cannot allocate an array of constant size 0
        .\cvtest.cpp(61) : error C2133: ‘px’ : unknown size
        .\cvtest.cpp(61) : error C2466: cannot allocate an array of constant size 0
        .\cvtest.cpp(61) : error C2133: ‘py’ : unknown size

        • I have the same problem…. can it related to library? I´m using the library below:
          #include “stdafx.h”
          #include “cv.h”
          #include “highgui.h”

          error:
          .\RecconheceCirculo.cpp(31) : error C2466: cannot allocate an array of constant size 0
          .\RecconheceCirculo.cpp(31) : error C2133: ‘px’ : unknown size
          .\RecconheceCirculo.cpp(31) : error C2466: cannot allocate an array of constant size 0
          .\RecconheceCirculo.cpp(31) : error C2133: ‘py’ : unknown size
          .\RecconheceCirculo.cpp(91) : error C2065: ‘cout’ : undeclared identifier
          .\RecconheceCirculo.cpp(111) : error C2065: ‘cout’ : undeclared identifier
          .\RecconheceCirculo.cpp(113) : error C2065: ‘cout’ : undeclared identifier

    • 😉 Seems that is but a problem of c++ which concerns the definition of arrays in VS 2005. Due to the size of ‘px”py’ is unknown, ‘px”py’ redifination may be required, check it again, and feel free to change the codes as you want to.

      • I tested the code but :
        int px[0], py[0];
        gives me a problem. I use VS 2005 to compile it and it and the errors are :
        cvtest.cpp(61) : error C2466: cannot allocate an array of constant size 0
        .\cvtest.cpp(61) : error C2133: ‘px’ : unknown size
        .\cvtest.cpp(61) : error C2466: cannot allocate an array of constant size 0
        .\cvtest.cpp(61) : error C2133: ‘py’ : unknown size

        I am using VS2008 to execute this program>>
        could you tell me how to redefine px and py, so they could be no problems for the program?

  5. Hi ,
    that’s interesting project , thank you.
    I just started in OpenCV . I need to get the coordinate of a polygon on image , could you advise which function in OpenCV I should use ?

  6. dear andol, my opencv refuses to run, was wondering if you could help?

    im running unbuntu 10.4

    so far:

    Downloaded source code for open cv+dependcys

    Used cmake to create a new build folder

    now im stuck ;/

    everysingle guide on the internet seems not to work, im new to linux yesterday so im not to sure on how to configure it to work.

    many thanks

    Acido

Leave a comment
Due to technical adjustments, the comment function is shortly closed and will be re-openning soon. Thanks.


Copyrights 2006-2017 © All rights reserved
Theme Tree2, re-designed by Andol Li, powered by WordPress and Bootsrap
WWW.ANDOL.ME | 浙ICP备15040508号-1
公安备案图标 浙公网安备33010602004018号
Back to top