Hough Circle Transformation:
1#include <opencv2\opencv.hpp>2#include <iostream>3#include <string>4#include <vector>5 6 #pragmaComment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")7 8 using namespacestd;9 using namespaceCV;Ten One voidShowimg (Const string&win_name,ConstMat &img) A { - Namedwindow (Win_name, cv_window_autosize); - imshow (Win_name, IMG); the } - - intMainvoid) - { +Mat src = imread ("panzi.jpg"); - if(Src.empty ()) + return-1; A Mat DST; at Cvtcolor (SRC, DST, cv_bgr2gray); -Showimg ("DST", DST); -Gaussianblur (DST, DST, Size (9,9),2,2); -Vector<vec3f>circles; -Houghcircles (DST, circles, cv_hough_gradient,1, Dst.rows/8, $, -,0,0); - for(size_t i =0; I < circles.size (); ++i) in { -Point Center (Cvround (circles[i][0]), Cvround (circles[i][1])); to intRadius = Cvround (circles[i][2]); +Circle (SRC, center,3, Scalar (0,255,0), -1,8,0);//Draw Center -Circle (SRC, center, radius, Scalar (0,0,255),3,8,0);//Draw a circle the } *Showimg ("After ciecle decete", SRC); $ Waitkey ();Panax Notoginseng return 0; -}
Test results:
Visible on the left side of the plate is not checked out, but do not know what is going on, maybe the left side is not a circle
Results of Split detection:
Right:
Left:
Because it cannot be distinguished by the naked eye, so the above results are not OK.
Above.
OPENCV Official Document Learning record (18)