当前位置: 代码迷 >> 综合 >> Halcon 排线检测|固定颜色检测
  详细解决方案

Halcon 排线检测|固定颜色检测

热度:82   发布时间:2024-01-30 00:15:26.0

上结果:
在这里插入图片描述
上原图:
在这里插入图片描述
贴代码:

dev_close_window ()
dev_open_window (0, 0, 640, 480, 'black', WindowHandle)
for i := 1 to 2 by 1* 读图像read_image (Image, 'cable' + i)* 将图像中的R G B三个分量分出来decompose3 (Image, Red, Green, Blue)* 将R G B分量图像转为H S V分量图像trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')* 将S分量图像进行阈值处理threshold (Saturation, HighSaturation, 100, 255)* 从H分量图像中抠图reduce_domain (Hue, HighSaturation, HueHighSaturation)* 针对H分量中抠出的图进行阈值处理threshold (HueHighSaturation, Yellow, 20, 50)* 计算连通域,得到连通域connection (Yellow, ConnectedRegions)* 选择面积最大的形状select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 0)* 闭运算closing_circle (SelectedRegions, Yellow, 3.5)* 抠图,将黄色从原始图像中抠出来reduce_domain (Image, Yellow, ImageReduced)* 显示dev_display (HueHighSaturation)dev_display (ImageReduced)stop ()
endfor