关于HalconDeeplearn中的语义分割的实现
1.读取数据和数据集
read_dl_model ('C:/Users/user/Desktop/大蒜测试/包裹/model_训练-240926-191345_opt.hdl', DLModelHandle)
read_dict('C:/Users/user/Desktop/大蒜测试/包裹/model_训练-240926-162708_opt_dl_preprocess_params.hdict',[], [], DLDataset)
2.读取识别图片
ImageFiles := []
ImageFiles[0] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-083830-959230.jpg'
ImageFiles[1] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-083834-273746.jpg'
ImageFiles[2] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-083836-991845.jpg'
ImageFiles[3] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-083846-42125.jpg'
ImageFiles[4] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-083954-81354.jpg'
ImageFiles[5] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084011-874589.jpg'
ImageFiles[6] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084046-108724.jpg'
ImageFiles[7] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084055-229775.jpg'
ImageFiles[8] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084133-608364.jpg'
ImageFiles[9] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084135-931095.jpg'
ImageFiles[10] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084248-960299.jpg'
ImageFiles[11] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084258-532255.jpg'
ImageFiles[12] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-084302-415268.jpg'
ImageFiles[13] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-085633-799217.jpg'
ImageFiles[14] := 'C:/Users/user/Desktop/大蒜测试/包裹/测试/chn5-w2560-h1440-19700101-085640-892212.jpg'
3.识别
* Create dictionaries used for the visualization.
WindowDict := dict{}
get_dl_model_param (DLModelHandle, 'class_ids', ClassIds)
get_dl_model_param (DLModelHandle, 'class_names', ClassNames)
DLDatasetInfo := dict{class_ids: ClassIds, class_names: ClassNames}
create_dl_preprocess_param_from_model(DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
for IndexInference := 0 to |ImageFiles|-1 by 1read_image (Image, ImageFiles[IndexInference])gen_dl_samples_from_images (Image, DLSampleInference)preprocess_dl_samples (DLSampleInference, DLPreprocessParam)apply_dl_model (DLModelHandle, DLSampleInference, [], DLResult)* dev_display_dl_data (DLSampleInference, DLResult, DLDatasetInfo, 'bbox_result', [], WindowDict)dev_disp_text ('Press F5 to continue', 'window', 'bottom', 'right', 'black', [], [])stop ()
endfor
dev_close_window_dict (WindowDict)