二维码读取之ecc200_small_modules_robustness.hdev

*这个实例演示了如何读取非常小的ECC200二维码

  • This example program shows how to find and decode ECC200 symbols
  • that have a very small module size.
  • 为了成功读取到这些条码,二维码的’small_modules_robustness‘的默认值是low,必须设置为high
    *robustness:翻译为鲁棒性,实际意思就是,抗干扰能力,稳定性,可读性,适应性
    *另外,module_size_min也应该设置为可能的最小值,这里为1。
  • To read these symbols successfully, the parameter
  • ‘small_modules_robustness’, which is set to ‘low’ by default, must
  • be set to ‘high’. Additionally, the parameter ‘module_size_min’
  • has to be set to the minimum expected module size, in this case
  • to the value 1.
    *为了展示small_modules_robustness这个参数的影响。改变这个值为low和high,读取两次条码做对比
  • In order to show the influence of the parameter ‘small_modules_robustness’
  • on the data code reader, the operator find_data_code_2d is called
  • twice with different settings of the regarding parameter.
  • 关闭更新
    dev_update_off ()
    *关闭窗体
    dev_close_window ()
    *读取图像
    read_image (Image, ‘datacode/ecc200/ecc200_cpu_001’)
    *缩放比例开始值:把图像缩小(缩小二维码),读取结果显示做比较
    ZoomFactorStart := 0.8
    *缩放图像
    zoom_image_factor (Image, ImageZoomed, ZoomFactorStart, ZoomFactorStart, ‘constant’)
    *开启适合图像大小的窗体
    dev_open_window_fit_image (ImageZoomed, 0, 0, -1, -1, WindowHandle1)
  • 打开第二个窗体,与第一个窗体尺寸一样大
  • Open a second window with in the same size as the first window
    *获取窗体尺寸
    get_window_extents (WindowHandle1, Row, Column, WidthOriginal, HeightOriginal)
    *打开第二个窗体,左上角坐标为:0,WidthOriginal + 10
    dev_open_window_fit_size (0, WidthOriginal + 10, WidthOriginal, HeightOriginal, -1, -1, WindowHandle2)
    *设置显示线宽
    dev_set_line_width (2)
  • 分别创建两个二维码读取器。一个small_modules_robustness设置为high,另一个设置为low;设置模块最小SIZE为1
  • Create two ECC 200 data code models for ‘small_modules_robustness’ set to ‘high’
  • and ‘small_modules_robustness’ set to ‘low’, respectively (set ‘module_size_min’ to 1).
    *创建两个二维码读取器
    create_data_code_2d_model (‘Data Matrix ECC 200’, [‘small_modules_robustness’,‘module_size_min’], [‘high’,1], DataCodeHandle1)
    create_data_code_2d_model (‘Data Matrix ECC 200’, [‘small_modules_robustness’,‘module_size_min’], [‘low’,1], DataCodeHandle2)
  • 循环过程中,图像逐渐变小,用两个二维码读取器读取二维码,并在两个窗体中显示对比结果
  • Within the loop:
    • In each iteration step, the image is scaled down again
    • Find the data code with ‘small_modules_robustness’ set to ‘high’
    • Find data code with ‘small_modules_robustness’ set to ‘low’
    • Display the results for each setting in different windows
      Size := 16
      for ZoomFactor := ZoomFactorStart to 0.3 by -0.1
      *逐步缩小图像
      zoom_image_factor (Image, ImageZoomed, ZoomFactor, ZoomFactor, ‘constant’)
      *
      *设置窗体1显示字体,窗体尺寸会随之变化
      set_display_font (WindowHandle1, Size, ‘mono’, ‘true’, ‘false’)
      *设置窗体2显示字体
      set_display_font (WindowHandle2, Size, ‘mono’, ‘true’, ‘false’)
      Size := Size - 1
      • 用small_modules_robustness为high的二维码读取器读取二维码
      • Find data code with ‘small_modules_robustness’ set to ‘high’
        find_data_code_2d (ImageZoomed, SymbolXLDs1, DataCodeHandle1, [], [], ResultHandles1, DecodedDataStrings1)
        • 用small_modules_robustness为low的二维码读取器读取二维码
      • Find data code with ‘small_modules_robustness’ set to ‘low’
        find_data_code_2d (ImageZoomed, SymbolXLDs2, DataCodeHandle2, [], [], ResultHandles2, DecodedDataStrings2)
      • 在两个窗体中分别显示两种结果
      • Display the results for both settings
        if (Size < 11)
        Message := ‘Small modules robustness:\n’
        else
        Message := ‘Small modules robustness: ’
        endif
        *当small_modules_robustness为’ high’时
      • For ‘small_modules_robustness: high’
        *激活窗体1
        dev_set_window (WindowHandle1)
        *重构窗体尺寸
        dev_resize_window_fit_image (ImageZoomed, 0, 0, 1000, 1000)
        *设置线宽
        dev_set_line_width (2)
        *显示图像
        dev_display (ImageZoomed)
        *在窗体1显示信息
        disp_message (WindowHandle1, Message + ‘high’, ‘window’, 4, 4, ‘black’, ‘true’)
        *显示结果
        disp_results (SymbolXLDs1, WindowHandle1, DataCodeHandle1, ResultHandles1, DecodedDataStrings1)
        *当small_modules_robustness为’low’时
      • For ‘small_modules_robustness: low’
        *激活窗体2
        dev_set_window (WindowHandle2)
        *重构窗体尺寸
        dev_resize_window_fit_image (ImageZoomed, 0, WidthOriginal + 10, 1000, 1000)
        *显示图像
        dev_display (ImageZoomed)
        *在窗体2显示信息
        disp_message (WindowHandle2, Message + ‘low’, ‘window’, 4, 4, ‘black’, ‘true’)
        *显示结果
        disp_results (SymbolXLDs2, WindowHandle2, DataCodeHandle2, ResultHandles2, DecodedDataStrings2)
        *右下角显示"Press F5 TO CONTINUE "这个信息
        disp_continue_message (WindowHandle2, ‘black’, ‘true’)
        stop ()
        endfor
  • 清除窗体句柄,释放内存
  • Clear the data code model
    clear_data_code_2d_model (DataCodeHandle1)
    clear_data_code_2d_model (DataCodeHandle2)
    *关闭窗体
    dev_close_window ()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值