Showing posts with label Hough Transform. Show all posts
Showing posts with label Hough Transform. Show all posts

3/14/2017

what is dp parameter in Hough Circle detection on opencv.


dp parameter is about resolution of voting space.
dp is larger, voting resolution is small compare to image size.
so dp is larger, circle detection accuracy is not exact.
but dp is smaller, voting resolution is higher and circle detection is more accurate but that sensitive with noise ex)other edge..
I increase dp from 1 to 5 step by 0.1..

refer to this source code on here.


< gist code >

< end gist >


and result image.








....

and other reference.
opencv org


stack overflow

python opencv tutorial

#tags
GaussianBlur, HoughCircles, CV_HOUGH_GRADIENT,

8/29/2011

Hough Transform (Line, Circle) / C++ source (OpenCV) / ํ—ˆํ”„๋ณ€ํ™˜(์„ , ์›)


Created Date : 2007.7
Language : C++
Tool : Visual C++ 6.0
Library & Utilized : OpenCV 1.0(for image saving)
Reference :  Hough Transform reference
etc. : -






This is Hough Transform program.
We can progress two type Hough Transform. One is Line Hough Transform, Second is Circle Hough Transform.
After processing, Hough Transform result, Edge Image and Parameter Space(txt) files save in your directory.

You can download source code <here>.

If you have good idea or advanced opinion, please reply me. Thank you
(Please understand my bad english ability. If you point out my mistake, I would correct pleasurably. Thank you!!)
-------------------------------------------------------------------------------

▣ ํ—ˆํ”„๋ณ€ํ™˜ ํ”„๋กœ๊ทธ๋žจ ๊ฒฐ๊ณผ
<์‹คํ—˜ 1>
1. ์ž…๋ ฅ ๋ฐ์ดํ„ฐ
2. ์—์ง€ ์˜์ƒ
3. Line ๊ฒ€์ถœ ๊ฒฐ๊ณผ
4. Parameter Space voting ์˜์ƒ

▣ ์†Œ์Šค ์ฝ”๋“œ ์„ค๋ช…
1. Line ๊ฒ€์ถœ
①voting ๋ถ€๋ถ„
theta๋ฅผ 0~180๊นŒ์ง€ ์ฆ๊ฐ€์‹œํ‚ค๋ฉด์„œ rho๋ฅผ ๊ตฌํ•˜๊ณ  ๊ทธ ๊ฐ’์„ [theta][rho]์˜ 2์ฐจ์› ๋ฐฐ์—ด์— Votingํ•œ๋‹ค.

②Sorting ๋ถ€๋ถ„
voting๋œ Parameter๋ฅผ ์ •๋ ฌํ•œ๋‹ค. ์ •๋ ฌ์€ STL์„ ์‚ฌ์šฉํ•จ.

③Line ๊ทธ๋ฆฌ๋Š” ๋ถ€๋ถ„
์ •๋ ฌ๋œ theta์™€ rho๊ฐ’์„ ์ด์šฉํ•˜์—ฌ ์ง์„ ์˜ ๋ฐฉ์ •์‹์˜ ๊ธฐ์šธ๊ธฐ์™€ ์ ˆํŽธ์„ ๊ตฌํ•˜๊ณ  OpenCV์— Line Drawํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ผ์ธ์„ ๊ทธ๋ฆฐ๋‹ค. ๊ทธ๋ ค์ง„ ๋ผ์ธ์€ OpenCV์˜ IplImage์— ์ €์žฅ๋œ๋‹ค.
๋ผ์ธ์„ ๊ทธ๋ฆด ๋•Œ๋Š” voting์ด ๊ฐ€์žฅ ๋งŽ์ด ๋œ ๊ฒƒ์˜ ์„ ์ƒ‰์„ 255, ๊ฐ€์žฅ voting์ด ์•ˆ๋œ ๊ฒƒ์˜ ์„  ์ƒ‰์„ 0์œผ๋กœ, Voting๋œ ๊ฒƒ์˜ ์ •๋„๋ฅผ ์ƒ‰์œผ๋กœ ๋‚˜ํƒ€๋‚ด์—ˆ๋‹ค.

2. Circle ๊ฒ€์ถœ
①voting ๋ถ€๋ถ„
๋ฐ˜์ง€๋ฆ„์„ <10>์—์„œ <์ด๋ฏธ์ง€ ๋Œ€๊ฐ๋ฐฉํ–ฅ์˜ ํ”ฝ์…€ ๊ธธ์ด ๋นผ๊ธฐ 10>๊นŒ์ง€ ์ฆ๊ฐ€์‹œํ‚ค๋ฉด์„œ theta๋ฅผ 0~360๊นŒ์ง€ ์ฆ๊ฐ€์‹œํ‚ค๋ฉฐ, ์›์˜ ์ค‘์‹ฌ ์œ„์น˜ Cx, Cy์— ๋Œ€ํ•˜์—ฌ voting์„ ํ•œ๋‹ค. voting๋œ ๊ฒฐ๊ณผ๋Š” ๋ฅผ ๋‹ด์„ ์ˆ˜ ์žˆ๋Š” Vector์— ์ €์žฅ๋œ๋‹ค.

②Sorting ๋ถ€๋ถ„
์˜ ์ •๋ณด๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” Vector์—์„œ Voring ๊ฐ’์œผ๋กœ ์ •๋ ฌ์„ ํ•œ๋‹ค.

③Circle ๊ทธ๋ฆฌ๋Š” ๋ถ€๋ถ„
์ •๋ ฌ๋œ ์›์ค‘์—์„œ ์ƒ์œ„ 1%๋งŒ ๋“œ๋กœ์ž‰ํ•œ๋‹ค.
๋“œ๋กœ์ž‰ํ•  ๋•Œ๋Š” ๋ผ์ธ์„ ๊ทธ๋ฆด๋•Œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ œ์ผ ๋งŽ์ด voting๋œ ๊ฒƒ์„ 255์ƒ‰, ์ œ์ผ ์ ๊ฒŒ voting๋œ๊ฒƒ์„ 0์ƒ‰์œผ๋กœ ๊ทธ๋ ค์„œ voting์ •๋„๋ฅผ ํ‘œ์‹œํ•œ๋‹ค.

▣ ์ธํ„ฐํŽ˜์ด์Šค ์„ค๋ช…
์‹คํ–‰ ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์—ฌ ํŒŒ์ผ๋ช…์„ ์ž…๋ ฅํ•˜๊ณ , Line์„ ๊ฒ€์ถœํ•˜๋ ค๋ฉด 1์„ ์ž…๋ ฅ Circle์„ ๊ฒ€์ถœํ•˜๋ ค๋ฉด 2๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
๊ฒ€์ถœ์ด ๋๋‚˜๋ฉด ์‹คํ–‰ ์‹œ๊ฐ„์ด ๋‚˜์˜จ๋‹ค.


์ „์ฒด ์†Œ์†Œ๋Š” ์—ฌ๊ธฐ์„œ ๋‹ค์šด ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <here>

์ข‹์€ ์˜๊ฒฌ ์–ด๋–ค ๊ธ€์ด๋“  ๋‹ต๋ณ€ ๋‚จ๊ฒจ์ฃผ์„ธ์š”
๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.