代码拉取完成,页面将自动刷新
<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="19.11.0.0">
<procedure name="main">
<interface/>
<body>
<c>*** 测试 ***</c>
<l>dev_update_off ()</l>
<c>**设置路径</c>
<c>*总路径</c>
<l>DataDir := 'C:/Users/75615/Desktop/检测1'</l>
<c>*图片路径</c>
<l>HalconImageDir:= DataDir + '/coinImage/'</l>
<c>*读模型</c>
<l> read_dl_model ('model_best.hdl', DLModelHandle)</l>
<c></c>
<c> *数据集路径</c>
<l>PillBagHdictFile := DataDir + '/coin_data.hdict'</l>
<c> *读取数据集</c>
<l>read_dict (PillBagHdictFile, [], [], DLDataset)</l>
<c>*获取数据集ID给到模型参数</c>
<l>get_dict_tuple (DLDataset, 'class_ids', ClassIDs)</l>
<l>set_dl_model_param (DLModelHandle, 'class_ids', ClassIDs)</l>
<c> *从模型中获取预处理参数</c>
<l>create_dict (GenParam)</l>
<l>set_dict_tuple (GenParam, 'overwrite_files', true)</l>
<l>create_dl_preprocess_param_from_model (DLModelHandle, 'false', 'full_domain', [], [], [], DLPreprocessParam)</l>
<l>create_dict (WindowDict)</l>
<c>*获取该路径下的所有图片 </c>
<l>list_image_files (HalconImageDir, 'default', 'recursive', ImageFiles)</l>
<c>*对图片文件进行随机排序</c>
<l>tuple_shuffle (ImageFiles, ImageFilesShuffled)</l>
<c>*每次读取一张</c>
<l>set_dl_model_param (DLModelHandle, 'batch_size', 1)</l>
<l>for i := 0 to |ImageFiles|-1 by 1</l>
<l> read_image (Image, ImageFilesShuffled[i])</l>
<l> gen_dl_samples_from_images (Image, DLSampleInference)</l>
<l> preprocess_dl_samples (DLSampleInference, DLPreprocessParam)</l>
<l> apply_dl_model (DLModelHandle, DLSampleInference, [], DLResult)</l>
<c> *为一个示例可视化不同的图像、注释和推理结果。</c>
<l> dev_display_dl_data (DLSampleInference, DLResult, DLDataset, 'bbox_result', [], WindowDict) </l>
<l> dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])</l>
<l> stop ()</l>
<l>endfor</l>
<c>*关闭可视化窗体</c>
<l>dev_display_dl_data_close_windows (WindowDict)</l>
</body>
<docu id="main">
<parameters/>
</docu>
</procedure>
</hdevelop>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。