Attention! This forum will be made read-only by Dec-20. Please migrate to https://forum.opencv.org. Most of existing active users should've received invitation by e-mail.
Ask Your Question
1

HoughCircles problem. C++.

asked 2016-03-31 13:04:04 -0500

BartBB2 gravatar image

updated 2020-09-22 17:54:46 -0500

I am trying to detect the amount of circles in an image. Apparently I either do not know how to use HoughCircles (which is the most likely scenario :D) or it simply is not good enough.

Not much to say, I'll upload a picture and post my code and hopefully you'll be able to help me out.

Picture with circles (which cannot be detected): http://imgur.com/2SmvysV

Code: http://pastebin.com/0M62cYmr

I seriously took the code from the internet. Made minor changes like param1 and param2 were changed to 80 instead of 100 in the HoughCircles function.

Previous post for the interested ones: http://answers.opencv.org/question/89...

EDIT: As I said, it either does not detect any dots/circles at all or detects fake ones. Any kind of help is appreciated!

edit retag flag offensive close merge delete

Comments

I seriously took the code from the internet. Made minor changes like param1 and param2 were changed to 80 instead of 100 in the HoughCircles function. --> Apart from the very helpfull post of @jmbapps your problem is actually the fact that you are grabbing the code from the internet and that you have no knowledge of what the code is doing and what the parameters are specifying. In the future, start by reading op on techniques and you will get much faster to a solution then depending on others...

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-01 03:10:10 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-03-31 13:28:17 -0500

jmbapps gravatar image

updated 2016-03-31 13:52:57 -0500

Staring with 'dp' try 2,50,35,50,20,30 as the last six parameters for HoughCircles. This is the result of my app with these parameters. These start after the 'method' parameter CV_HOUGH_GRADIENT in C++. Even false circles will give you an idea of how to adjust the parameters. The last two are size, so if the false circles are too big, you need to drop these two parameters. If the circles are too small, then you need to increase the last two. The worst is when you dont detect any, then just lower the param2 setting until something shows up. Also if none of the circles overlap, you should generally set your minDist to double what ever your minRadius setting is. Hope that makes sense. Taken from the pic below as parameter structure.

Documentation

Find Circles

edit flag offensive delete link more

Comments

1

It works! Thanks a lot! I had no idea I should change the settings like that. I was only messing around with param1 and param2. Saved my ass, thanks.

BartBB2 gravatar imageBartBB2 ( 2016-03-31 14:00:03 -0500 )edit
1

Glad I could help. The info online is lacking for sure. Understanding what each parameter does is crucial.

jmbapps gravatar imagejmbapps ( 2016-03-31 16:40:36 -0500 )edit

@jmbapps, if you think the online documentation is seriously lacking, then could you maybe provide some updates to the documentations by a contribution through a pull request?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-01 03:11:31 -0500 )edit

Steven, I thought I said info and not documentation. Didnt I post a pic of some documentation? If the attitude of the development community was a bit more helpful, then I would post a pull request. Unfortunately I encountered absolutely no online assistance at all, just immature attitudes from places like Stack Overflow. Learning to develop cost me my life. Sitting for 16 hours a day for 4 months was more than my crunched spine could bare. Now I am crippled from permanent nerve damage, every step I take is very paintful. My time is precious and I have many, many projects still to finish in my lifetime. First of which is restoring my 5.0 mustang, then finish up some airbrush art I have been staring at for years. Then maybe...just maybe I will contribute to the opencv community.

jmbapps gravatar imagejmbapps ( 2016-04-01 07:45:20 -0500 )edit

@jmbapps I think you completely misunderstood my point :) I was encouraging you to, if you think something could be added further to the docs to make it better, that you could supply it. Certainly because I am aware of the lacking info around and thus am all in favor of bringing as much info as possible to the correct location, in my point of view, the docs...

As to being helpfull as an attitude, sorry but I think you are barking against the wrong tree here. I spent more then enough of my spare time here to help out other developers... simply because I am sure that it will help the community in the long haul. As to the back issues, welcome to the club :) Life of a programmer I guess.

Thanks for your clear answer btw! I am sure it helped @BartBB2 out!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-01 07:52:37 -0500 )edit
1

I was active before that my entire life. I am not a programmer, I am a construction worker, union electrician, backyard mechanic, sheet metal fab guy, musician, artist. I learned to program in 9th grade on a PETS computer in basic. It is my fault for being so intense when a challenge arrises. In 4 months I learned to use a Mac when PC is all I had ever owned. Stumbled across Xcode, learned C, C++, Objective C, and bit of Objective C++, import opencv into Xcode for iOS development...and successfully created two apps. I thought it would be a nice extra income, what I got was cuada equina syndrome. I would be happy to issue pull request, if I knew how. ;o) Sorry for the rant. You are right, most are copy/paste coders. I try to explain the why behind the how.

jmbapps gravatar imagejmbapps ( 2016-04-01 08:08:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-31 13:04:04 -0500

Seen: 2,131 times

Last updated: Mar 31 '16