Ask Your Question
0

How to use opencv to find circles

asked 2013-10-03 05:46:02 -0600

I get a picture,but it's format is YUV422,I want to find circles in it,how should I do? Thank you!

edit retag flag offensive close merge delete

Comments

Try HoughCircles. Should work(:

rockinfresh gravatar imagerockinfresh ( 2013-10-03 06:45:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-10-03 08:22:08 -0600

ThomasB gravatar image

updated 2013-10-03 08:23:04 -0600

Adopt this code: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html#code

To operate with YUV422 images, try the following modification to the mentioned code sample;

Mat src, src_gray;

src = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);

if( !src.data )
{ return -1; }

// YUV422 has 1.5 times the height of the captured frame when read as grayscale, thus you can extract the grayscale by using the two upper thirds of the image only
Rect grayscaleImageAra(0,0,src.cols, src.rows*2/3);
src_gray = src(grayscaleImageAra); // crop the Grayscale part fromt he YUV422 image


// FROM THIS LINE UNCHANGED CODE FROM http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html#code
/// Reduce the noise so we avoid false circle detection
GaussianBlur( src_gray, src_gray, Size(9, 9), 2, 2 );

// ..... //
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-03 05:46:02 -0600

Seen: 549 times

Last updated: Oct 03 '13