halcon AI读取onnx模型并推理
*程序功能:读取onnx模型并推理
dev_update_off()
dev_close_window ()
read_dl_model ('squeezenet.onnx', DLModelHandle)
set_dl_model_param (DLModelHandle, 'type', 'classification')
get_dl_model_param(DLModelHandle, 'image_dimensions', ImageDimensions)
get_dl_model_param(DLModelHandle, 'class_names', ClassNames)
get_dl_model_param(DLModelHandle, 'class_ids', ClassIds)
set_dl_model_param (DLModelHandle, 'runtime_init', 'immediately')
dev_open_window(0, 0, 600, 400, 'black', WindowHandle)
set_font(WindowHandle, 'Microsoft YaHei UI-Bold-36')
read_image (Image, 'cat.jpg')
zoom_image_size (Image, ImagePreprocessedByte, ImageDimensions[0], ImageDimensions[1], 'constant')
convert_image_type (ImagePreprocessedByte, ImagePreprocessed, 'real')
scale_image (ImagePreprocessed, ImagePreprocessed, 1, -127)
create_dict (DLSample)
set_dict_object (ImagePreprocessed, DLSample, 'image')
apply_dl_model (DLModelHandle, DLSample, [], DLResult)
get_dict_tuple (DLResult, 'classification_confidences', Confidences)
get_dict_tuple (DLResult, 'classification_class_names', PredictClasses)
tuple_max (Confidences, Max)
tuple_find (Confidences, Max, IndexMax)
dev_clear_window ()
dev_display(Image)
Text := PredictClasses[IndexMax] + ', ' + Max$'.2f'
dev_disp_text (Text, 'window', 'top', 'left', 'red', 'box', 'false')
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了