一维码和二维码读取模型解码

1.一维码

read_bar_code_model( : : FileName : BarCodeHandle)

函数说明:从一个文件中读取一个一维条码模型并新建一个模型

函数参数:

        FileName:输入要读取的一维码模型文件,文件的后缀为.dcm

        BarCodeHandle:输出一维码模型句柄

以下代码为 Code 128 类型条码,调用模型的实例:

*一维码
read_image (Image, 'D:/kaycee_yu/Desktop/halcon/20231107141225484.bmp')          
gen_rectangle1 (Rectangle, 3376.81, 2042.71, 4113.43, 3368.12)
reduce_domain (Image, Rectangle, Image)
dev_display (Image)

*优化条码图像
decompose3 (Image, Image1, Image2, Image3)
scale_image (Image1, ImageScaled, 3, -300)
emphasize (ImageScaled, ImageEmphasize, 9, 9, 1)  
zoom_image_factor (ImageEmphasize, ImageZoomed, 0.5, 0.5, 'constant')
dev_display (ImageZoomed)   

*创建条码模型
* create_bar_code_model ([], [], BarCodeHandle) 
read_bar_code_model ('Code 128.dcm', BarCodeHandle)
find_bar_code (ImageZoomed, SymbolRegions1, BarCodeHandle, ['Code 128'], BarCodeStrings)

*清除条码模型
clear_bar_code_model (BarCodeHandle)
stop ()

2.二维码

read_data_code_2d_model( : : FileName : DataCodeHandle)

函数说明:从一个文件中读取一个二维条码模型并新建一个模型

函数参数:

        FileName:输入要读取的二维码模型文件,文件的后缀为.dcm

        BarCodeHandle:输出二维码模型句柄

以下代码为Data Matrix ECC 200 类型二维码,调用模型实例:

*二维码
read_image (Image, 'D:/kaycee_yu/Desktop/halcon/20231107141225484.bmp')          
gen_rectangle1 (Rectangle, 2495.6, 2649.86, 2997.91, 2968.88)
reduce_domain (Image, Rectangle, Image)
dev_display (Image)

*优化条码图像
decompose3 (Image, Image1, Image2, Image3)
scale_image (Image1, ImageScaled, 6, -300)
emphasize (ImageScaled, ImageEmphasize, 9, 9, 1)  
zoom_image_factor (ImageEmphasize, ImageZoomed, 0.5, 0.5, 'constant')
dev_display (ImageZoomed)   

*创建条码模型
* create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', BarCodeHandle)
read_data_code_2d_model ('Data Matrix ECC 200.dcm', DataCodeHandle)
find_data_code_2d (ImageZoomed, Contour, DataCodeHandle, 'train', 'all', ResultHandles, DecodedDataStrings)

*清除条码模型
clear_bar_code_model (BarCodeHandle)
stop ()

提示:1.以上代码只单独调用的单一条码类型模型,要其他条码类型模型需要创建其他模型调用。

2.halcon中有二维码模型创建实例 ecc200_training.hdev(训练2D数据代码模型,将模型写入文件,然后读取模型),暂未研究。

3.优化条码图像:scale_image (Image1, ImageScaled, 3, -300),根据实际情况,可以自行调整这两个值的大小

4.模型包下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

susan花雨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值