Halcon深度学习-企业项目实战(芯片贴合外观缺陷检测)
1、项目需求
缺陷说明:
2、收集相关的缺陷图片:
OK图片地址:
链接:CSDN下载地址
备注:其他下载地址私信联系
NG图片地址:
链接:SCDN下载地址
备注:其他下载地址私信联系
3、缺陷图片分析、标注图像:
标注过程视频地址:
标注文件地址:
链接: SCDN下载地址
备注:其他下载地址私信联系
4、Halcon深度学习代码:
总体代码
dev_update_off ()
*读数据
read_dict ('123.hdict', [], [], DictHandle)
*Xml
* Xml_To_Dict_DeepBool ('Train_Images/JPEGImages', 'Train_Images/Temp', 'Xml', DictHandle)
*Dict_To_Xml
* Dict_To_Xml_DeepBool (DictHandle, 'Voc', 'Temp')
*by_num
* Cut_Images_bynum (DictHandle, 2, 2, 'png', 255, DictHandle)
*by_size
* Cut_Images_bysize (DictHandle, 800, 800, 'png', 255, DictHandle)
*[570,517,3]
*数据预处理
Data_preprocessing_Rectangle1 (1376, 928, 3, 'compact', DictHandle, 0, 'bmp', 255)
*训练
Data_Train_Rectangle1 (1, 0.0005, 0.9, 200, 0.0001, 1, false, 'gpu', [], [])
*模型评估
Data_Evaluate_Rectangle1 (0.5, 2, true, 0.7, 0.2, 0.5)
*推理初始化
Data_Infer_Init_Rectangle1 (1, 0.5, true, 0.2, 0.7, DLModelHandle, DLPreprocessParam)
dev_get_window (WindowHandle)
*Data_Infer_Online
get_dict_tuple (DictHandle,'class_names' , class_names)
list_files ('NG', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[Index])
Data_Infer_OnLine_Rectangle1 (Image, Rectangle, DictHandle, DLPreprocessParam, DLModelHandle, \
bbox_row1, bbox_col1, bbox_row2, bbox_col2, bbox_class_id, bbox_confidence)
ifelse (|bbox_class_id|)
gen_rectangle1 (Rectangle, bbox_row1, bbox_col1, bbox_row2, bbox_col2)
dev_clear_window ()
dev_display (Image)
boundary (Rectangle, Rectangle, 'inner')
dev_disp_text (class_names[bbox_class_id]+' : '+bbox_confidence, 'image', bbox_row1, bbox_col1, 'red', 'box', 'false')
dev_display (Rectangle)
else
dev_disp_text ('OK', 'image', 200, 200, 'red', 'box', 'false')
endif
* dump_window_image (Image1, WindowHandle)
* tuple_split (ImageFiles[Index], '\\', Substrings)
* write_image (Image1, 'jpg', 0, 'Data_Infer_Result/'+Substrings[|Substrings|-1])
endfor
5、训练结果展示:
已训练模型下载:
演示效果:
6、C# 引擎加载Halcon深度学习Demo:
7、项目资料下载地址:
链接: