前言
本文主要实现根据源图经过阈值来定位检测,主要用到的算子:
threshold
connection
select_shape
orientation_region
一、本次脚本使用的图片
二、halcon脚本如下
dev_get_window (WindowHandle)
read_image (Image, '11.png')
get_image_size (Image, Width, Height)
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 130, 238)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10000, 99999)
orientation_region (SelectedRegions, Phi)
area_center (SelectedRegions, Area, Row, Column)
dev_display (Image)
for L := 0 to |Area|-1 by 1
disp_cross (WindowHandle, Row[L], Column[L],20, Phi[L])
endfor