How to use opencv to find circles
I get a picture,but it's format is YUV422,I want to find circles in it,how should I do? Thank you!
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 );
// ..... //
Asked: 2013-10-03 05:46:02 -0600
Seen: 561 times
Last updated: Oct 03 '13
Try HoughCircles. Should work(: