1. 程式人生 > >Halcon_Hough變換檢測直線,檢測圓

Halcon_Hough變換檢測直線,檢測圓

read_image (Image, 'E:/Halcon_projects/Hough_LineCircle/HoughToFindLine.bmp')
* Detect edges (amplitude) using the Sobel operator
sobel_amp (Image, EdgeAmplitude, 'thin_sum_abs', 9)
dev_set_color ('red')
threshold (EdgeAmplitude, Region, 70, 255)
hough_lines (Region, 8, 400, 5, 5, Angle, Dist)
hough_line_trans(Region, HoughImage, 4)
dev_set_color ('blue')
* Store input lines described in HNF
gen_region_hline (Regions, Angle, Dist)
degree := deg(Angle)
//Circle detection

read_image(Image_circle,'E:/Halcon_projects/Hough_LineCircle/Circle_detection.jpg')
sobel_amp(Image_circle, EdgeAmplitude1, 'sum_abs', 5)
threshold(EdgeAmplitude1, Region_circle, 80, 255)
* Detect Circle 1
hough_circles(Region_circle, RegionOut1, 10, 80, 1)
connection(RegionOut1, ConnectedRegions1)
* Detect Circle 2
hough_circles(Region_circle, RegionOut2, 195, 70, 1)
hough_circle_trans(Region_circle, HoughImage1, 195)
connection(RegionOut2, ConnectedRegions2)