Halcon深度学习之实例分割

文章介绍了如何使用Halcon进行深度学习实例分割,作者分享了在特定数据集上操作的代码片段,包括预处理、模型应用和结果展示过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Halcon在21,11更新了最新的深度学习方法:实例分割,官方演示视频可以看这里:使用 HALCON 进行深度学习实例分割:MVTec 软件icon-default.png?t=N7T8https://www.mvtec.com/company/news/article/deep-learning-instance-segmentation-with-halcon

 这里我主要用了自己训练的网络模型进行了实例分割,可以给想使用自己的数据集实现halcon实例分割的朋友一个参考,下面直接贴代码

OutputDirPreprocessing := '../1'
TestImageFolder := 'G:/2D-3D/连杆_images/'
TestModelFolder :='G:/2D-3D/3DModel/'
DepthImageFolder :='G:/2D-3D/DepthImages/'
list_files (TestModelFolder, 'files', ModelFiles)
tuple_shuffle (ModelFiles, ModelFilesShuffled)
list_image_files (TestImageFolder, 'default', 'recursive', ImageFiles)
tuple_shuffle (ImageFiles, ImageFilesShuffled)
list_image_files (DepthImageFolder, 'default', 'recursive', DepthImageFiles)
tuple_shuffle (DepthImageFiles, DepthImageFilesShuffled)
read_dl_model ('G:/2D-3D/连杆模型.hdl', DLModelHandle)
read_dict ('G:/2D-3D/连杆.hdict', [], [], DLDataset)
find_dl_samples (DLDataset.samples, 'split', 'test', 'match', SampleIndices)
create_dl_preprocess_param_from_model (DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
preprocess_dl_dataset (DLDataset, OutputDirPreprocessing, DLPreprocessParam, dict{overwrite_files: 'auto'}, DLDatasetFileName)
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}
for IndexInference := 0 to |ImageFiles|-1 by 1 
    read_image (Image, ImageFilesShuffled[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)
    zoom_image_size (Image, ImageZoom, 1920, 1200, 'constant')  
    read_image (DepthImage, DepthImageFilesShuffled[IndexInference])    
    dev_disp_text ('Press F5 to continue', 'window', 'bottom', 'right', 'black', [], [])
    stop ()
endfor
dev_close_window_dict (WindowDict)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值