OPENCV Official Document Learning record (18)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.