Halcon识别旋转的一维码

原图

识别结果:

代码:

* 
* Orientation with reading direction of a bar code
* 
read_image (Image, 'barcode/ean13/ean1305')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (Image)
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
* 
create_bar_code_model ('element_size_min', 1.5, BarCodeHandle)
for Rot := 0 to 360 by 30
    rotate_image (Image, ImageRotate, Rot, 'weighted')
    dev_display (ImageRotate)
    get_image_size (ImageRotate, Width, Height)
    dev_set_window_extents (0, 0, Width, Height)
    find_bar_code (ImageRotate, SymbolRegions, BarCodeHandle, 'EAN-13', DecodedDataStrings)
    dev_display (SymbolRegions)
    get_bar_code_result (BarCodeHandle, 'all', 'orientation', Orientation)
    area_center (SymbolRegions, Area, Row, Col)
    gen_arrow_contour_xld (Arrow, Row + sin(rad(Orientation)) * 70, Col - cos(rad(Orientation)) * 70, Row - sin(rad(Orientation)) * 70, Col + cos(rad(Orientation)) * 70, 25, 25)
    dev_display (Arrow)
    disp_message (WindowHandle, DecodedDataStrings, 'window', 12, 12, 'black', 'true')
    if (Rot < 360)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor
* 
clear_bar_code_model (BarCodeHandle)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值