Halcon 解码算子详解 一

create_data_code_2d_model

create_data_code_2d_model( : : SymbolType, GenParamName, GenParamValue : DataCodeHandle)
create_data_code_2d_model (‘Data Matrix ECC 200’, [], [], DataCodeHandle)
创建数据二维代码模型

SymbolType (输入参数)

二维数据代码类型
默认值: ‘Data Matrix ECC 200’
参数集合:
‘Aztec Code’,
‘Data Matrix ECC 200’,
‘GS1 Aztec Code’,
‘GS1 DataMatrix’,
‘GS1 QR Code’,
‘Micro QR Code’,
‘PDF417’,
‘QR Code’

GenParamName(输入参数)

对模型进行调整的参数名称
**默认值:‘[ ]’
参数集合: ‘additional_levels’, ‘contrast_min’, ‘contrast_tolerance’, ‘default_parameters’, ‘finder_pattern_tolerance’, ‘mirrored’, ‘model_type’, ‘module_aspect’, ‘module_aspect_max’, ‘module_aspect_min’, ‘module_gap’, ‘module_gap_col’, ‘module_gap_col_max’, ‘module_gap_col_min’, ‘module_gap_max’, ‘module_gap_min’, ‘module_gap_row’, ‘module_gap_row_max’, ‘module_gap_row_min’, ‘module_grid’, ‘module_size’, ‘module_size_max’, ‘module_size_min’, ‘module_width’, ‘module_width_max’, ‘module_width_min’, ‘persistence’, ‘polarity’, ‘position_pattern_min’, ‘slant_max’, ‘small_modules_robustness’, ‘strict_model’, ‘strict_quiet_zone’, ‘symbol_cols’, ‘symbol_cols_max’, ‘symbol_cols_min’, ‘symbol_rows’, ‘symbol_rows_max’, ‘symbol_rows_min’, ‘symbol_shape’, ‘symbol_size’, ‘symbol_size_max’, ‘symbol_size_min’, ‘timeout’, ‘version’, ‘version_max’, ‘version_min’

在使用过程中常使用默认值‘[ ]’,详细设置会在创建模型后,set_data_code_2d_param中进行已知的、不同参数进行设置,来提高解码的精确性。

GenParamValue(输入参数)

对模型进行调整的参数的值
默认值:[ ]
参数集合:
‘standard_recognition’, ‘enhanced_recognition’, ‘maximum_recognition’, ‘yes’, ‘no’, ‘any’, ‘dark_on_light’, ‘’, ‘square’, ‘rectangle’, ‘small’, ‘big’, ‘fixed’, ‘variable’, ‘low’, ‘high’, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 30, 50, 70, 90, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40, 44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144

在使用过程中常使用默认值‘[ ]’,详细设置会在创建模型后,set_data_code_2d_param中进行已知的、不同参数进行设置,来提高解码的精确性。

DataCodeHandle(输出参数)

用于模型操作的句柄

案例

以下是找的隐形DM码,拍照后,进行解码测试的案例
在这里插入图片描述

* This example program shows how to read ECC200 symbols
* with heavily disturbed finder pattern. In this example,
* one or more sides of the finder pattern are deformed.
* Therefore some example images that contain ECC200 symbols
* with similar disturbances are used to train a data code model
* which is then used to find the data codes.
* 
* Note that alternatively, you can also set the parameter
* 'finder_pattern_tolerance' to 'high' with the operator
* set_data_code_2d_param or create_data_code_2d_model.
* 
* Initialize image path and visual settings
dev_update_off ()
dev_close_window ()
ImageFiles := 'E:/桌面/临时文件夹/img'
ImageFilesTrain := 'E:/桌面/临时文件夹/img'
read_image (Image, 'E:/桌面/临时文件夹/img/Image_20220216145827610.bmp')
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_line_width (3)
dev_set_color ('green')

* 
* Step 1: Create a 2d data code model
* ----------------------------------------------------
* Create a 2d data code model of the 2d data code class
* 'Data Matrix ECC 200'.
create_data_code_2d_model ('Data Matrix ECC 200', [], [], DataCodeHandle)
list_image_files ('E:/桌面/临时文件夹/img', 'default', [], ImageFiles1)
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles1[Index])
    * 
    * Find and decode the data codes
    find_data_code_2d (Image, SymbolXLDs, DataCodeHandle, 'train', 'all', ResultHandles, DecodedDataStrings)
    dev_display (Image)
    dev_display (SymbolXLDs)
*     TitleMessage := 'Train on image ' + Index + ' of ' + ImageTrainNum
*     display_found_data_codes (SymbolXLDs, WindowHandle, DecodedDataStrings, TitleMessage, [], 'forest green', 'black')
    disp_continue_message (WindowHandle, 'black', 'true')
    stop ()
endfor
* 
* Display message about the next step
* dev_clear_window ()
* Message := 'The trained data code model is now used to find the data codes'
* Message[1] := 'in a sequence of images with similar disturbances.'
* disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
* disp_continue_message (WindowHandle, 'black', 'true')
* stop ()
* 
* Step 3: Read the data codes
* -------------------------------------------------------
* Search and read the data codes with the trained model
* in each image and display the decoded string for each
* found data code
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles1[Index])
    dev_display (Image)
    * 
    * Find and decode the data codes and measure the runtime
    count_seconds (T1)
    find_data_code_2d (Image, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)
    count_seconds (T2)
    Time := (T2 - T1) * 1000.0
    * 
    * Display the results
*     TitleMessage := 'Image ' + Index + ' of ' + ImageNum
    ResultMessage := 'Data code found in ' + Time$'.1f' + ' ms'
    display_found_data_codes (SymbolXLDs, WindowHandle, DecodedDataStrings, '', ResultMessage, 'forest green', 'black')
    * 
    * If no data codes are found
    if (|ResultHandles| == 0)
        disp_message (WindowHandle, 'No Symbol found (in ' + Time$'.1f' + ' ms )', 'window', 12, 12, 'black', 'true')
    endif
    * 
    * Deactivate the following lines to run the program without breaks
    stop ()
endfor

* 
* Clear the data code model
clear_data_code_2d_model (DataCodeHandle)

在这里插入图片描述

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

漫伊

感谢打赏

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

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

打赏作者

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

抵扣说明:

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

余额充值