Halcon一维码读取

工作流程
使用的算子

*---------------------------------------------------------------------------------------------------------------------
*条码读取
*---------------------------------------------------------------------------------------------------------------------

* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('C:/Users/Public/Documents/MVTec/HALCON-19.11-Progress/examples/images/barcode/code128', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
    *读取图片
    read_image (Image, ImageFiles[Index])
    *创建一维条码模型
    create_bar_code_model ([], [], BarCodeHandle1)  
    *查找条码
    find_bar_code (Image, SymbolRegions, BarCodeHandle1, 'auto', DecodedDataStrings)
    *读取条码区域
    get_bar_code_object (BarCodeObjects, BarCodeHandle1, 'all', 'symbol_regions')
    *获取条码信息
    get_bar_code_result (BarCodeHandle1, 'all', 'decoded_strings', BarCodeResults)
    *清除条码信息
    clear_bar_code_model (BarCodeHandle1)
endfor

如果是要获取指定范围的方式可以采用抠图的方式 将指定位置的图片抠出 然后再识别
不如下面的图片
在这里插入图片描述

 *读取图片
    read_image (Image, 'C:/Users/宋书兵/Desktop/88_832728_1d2470c3917ee52.jpg')        
    rgb1_to_gray (Image, GrayImage)    
    dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
    dev_display (Image)
    *绘制ROI区域
    draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
    *获取指定大小区域
    gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
    *抠图改区域
    reduce_domain (GrayImage, Rectangle, ImageReduced)    
    *创建一维条码模型
    create_bar_code_model ([], [], BarCodeHandle1)             
    *查找条码
    find_bar_code (ImageReduced, SymbolRegions, BarCodeHandle1, 'auto', DecodedDataStrings)
    *读取条码区域
    *get_bar_code_object (BarCodeObjects, BarCodeHandle1, 'all', 'symbol_regions')
    *获取条码信息
    *get_bar_code_result (BarCodeHandle1, 'all', 'decoded_strings', BarCodeResults)
    *清除条码信息
    clear_bar_code_model (BarCodeHandle1)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值