classify_halogen_bulbs.hdev
本例程展示了通过提取区域形态特征(面积(Area)、密实度(Compactness)、四个不变矩特征(PSI1,PSI2,PSI3,PSI4)和凸度(Convexity)) 交给SVM训练 实现分类
原代码
get_system ('image_dir', HalconImages)
get_system ('operating_system', OS)
if (OS{
0:2} == 'Win')
tuple_split (HalconImages, ';', HalconImages)
else
tuple_split (HalconImages, ':', HalconImages)
endif
ReadOK := false
dev_get_preferences ('suppress_handled_exceptions_dlg', SaveMode)
dev_set_preferences ('suppress_handled_exceptions_dlg', 'true')
for k := 0 to |HalconImages| - 1 by 1
try
read_image (Image, HalconImages[k] + '/halogen_bulb/halogen_bulb_01.png')
ReadPath := HalconImages[k] + '/halogen_bulb/'
ReadOK := true
break
catch (Exception)
endtry
endfor