51Halcon机器视觉

 找回密码
 会员注册

QQ登录

只需一步,快速开始

扫一扫,微信登录

查看: 2780|回复: 3

求条码识别的理论资料

[复制链接]

该用户从未签到

3

主题

6

帖子

532

积分

Rank: 3

积分
532
发表于 2017-1-15 22:54:51 | 显示全部楼层 |阅读模式

51Halcon诚邀您的加入,专注于机器视觉开发与应用技术,我们一直都在努力!

您需要 登录 才可以下载或查看,没有帐号?会员注册

x
小弟想研究一下条码(包括二维码和一维码)的原理,比如,如何进行条码的目标检测,图像分割,最后如何识别的
不知道哪位大神能介绍一点资料或者源码?
小弟不胜感激

1.发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

2.提问请组织好自己的逻辑,标题注明大概是什么问题,问题内容写详细,需提供问题症状、错误代码、截图、位置等等信息,不要让别人去猜你想问啥;

3.如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

4.回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

  • TA的每日心情
    点赞
    昨天 10:11
  • 签到天数: 680 天

    连续签到: 1 天

    [LV.9]以坛为家II

    147

    主题

    759

    帖子

    4484

    积分

    Rank: 9

    积分
    4484

    热心会员突出贡献切换助手验证会员最佳新人

    发表于 2017-1-17 09:51:00 | 显示全部楼层

    RE: 求条码识别的理论资料

    这个是HALCON10.0的代码,你可以参考下:
    1. * Example program for the usage of the bar code
    2. * reader autodiscrimination feature of HALCON.
    3. *
    4. * Create bar code reader model
    5. create_bar_code_model ([], [], BarCodeHandle)
    6. *
    7. * Initialization
    8. dev_update_var ('off')
    9. dev_update_pc ('off')
    10. dev_update_window ('off')
    11. dev_close_window ()
    12. dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
    13. set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
    14. dev_set_draw ('margin')
    15. dev_set_line_width (3)
    16. dev_set_color ('forest green')
    17. *
    18. * Define the example images to use
    19. ExampleImagesAny := ['barcode/ean13/ean1301', 'barcode/code39/code3901', 'barcode/rss14/rss14_01']
    20. ExampleImagesAmbiguous := ['barcode/mixed/barcode_mixed_01']
    21. ExampleImagesMixed := ['barcode/mixed/barcode_mixed_04', 'barcode/mixed/barcode_mixed_03',   'barcode/mixed/barcode_mixed_01']
    22. *
    23. * Use autodiscrimination to decode any of the bar code types
    24. * supported by HALCON (except PharmaCode) or determine the bar
    25. * code type of unknown bar codes
    26. for IdxExample := 0 to 1 by 1
    27.     dev_clear_window ()
    28.     if (IdxExample = 0)
    29.         CodeTypes := 'auto'
    30.         Message := 'Usage of autodiscrimination to decode'
    31.         Message[1] := 'unknown bar code types.'
    32.         Message[2] := 'In the first run we use CodeType=\''+CodeTypes+'\' to look'
    33.         Message[3] := 'for all bar code types known to HALCON'
    34.         disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
    35.         disp_continue_message (WindowHandle, 'black', 'true')
    36.         stop ()
    37.     else
    38.         CodeTypes := ['EAN-13','Code 39','RSS-14']
    39.         Message := 'In the second run we look for the expected types only:'
    40.         Message[1] := sum('  ' + CodeTypes)
    41.         Message[2] := 'This reduces the decoding time and'
    42.         Message[3] := 'increases the decoding reliability.'
    43.         disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
    44.         disp_continue_message (WindowHandle, 'black', 'true')
    45.         stop ()
    46.     endif
    47.     for IdxIma := 0 to |ExampleImagesAny|-1 by 1
    48.         FileName := ExampleImagesAny[IdxIma]
    49.         read_image (Image, FileName)
    50.         *
    51.         * Set display defaults
    52.         get_image_size (Image, Width, Height)
    53.         dev_set_window_extents (-1, -1, Width, Height)
    54.         dev_display (Image)
    55.         disp_message (WindowHandle, ['Looking for bar code(s) of type:', sum(' ' + CodeTypes)], 'window', 12, 12, 'black', 'true')
    56.         *
    57.         * Find and decode bar codes. Measure the time needed.
    58.         count_seconds (Start)
    59.         find_bar_code (Image, SymbolRegions, BarCodeHandle, CodeTypes, DecodedDataStrings)
    60.         count_seconds (Stop)
    61.         Duration := (Stop - Start) * 1000
    62.         *
    63.         * Display results and the time needed
    64.         dev_display (SymbolRegions)
    65.         get_bar_code_result (BarCodeHandle, 'all', 'decoded_types', DecodedDataTypes)
    66.         disp_message (WindowHandle, ['Found bar code(s) in ' + Duration

    67. 3.0f' + 'ms:',' Type: ' + DecodedDataTypes + '\n Data: ' + DecodedDataStrings], 'window', 5*12, 12, 'forest green', 'true')
    68.         disp_continue_message (WindowHandle, 'black', 'true')
    69.         stop ()
    70.     endfor
    71. endfor
    72. *
    73. *
    74. * Autodiscrimination can be used to decode multiple bar code
    75. * types within one image at once.
    76. *
    77. * First we demonstrate that the bar code types list
    78. * should be confined whenever possible.
    79. *
    80. * Display information for the user:
    81. Message := 'If you have a list of bar code types that'
    82. Message[1] := 'you want to decode, you should supply only those'
    83. Message[2] := 'types to the bar code reader. In the following,'
    84. Message[3] := 'it is demonstrated that otherwise a wrong bar code'
    85. Message[4] := 'could be decoded (here: UPC-E Add-On 2)'
    86. dev_clear_window ()
    87. disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
    88. disp_continue_message (WindowHandle, 'black', 'true')
    89. stop ()
    90. *
    91. * For demonstration purposes we scan here, among others,
    92. * for UPC codes, too.
    93. CodeTypes := ['auto']
    94. *
    95. * Demonstrate autodiscrimination for mixed bar code types
    96. for IdxIma := 0 to |ExampleImagesAmbiguous|-1 by 1
    97.     FileName := ExampleImagesAmbiguous[IdxIma]
    98.     read_image (Image, FileName)
    99.     *
    100.     * Display image and description
    101.     get_image_size (Image, Width, Height)
    102.     dev_set_window_extents (-1, -1, Width/2, Height/2)
    103.     dev_display (Image)
    104.     disp_message (WindowHandle, ['Looking for bar code(s) of type:', sum(' ' + CodeTypes)], 'window', 12, 12, 'black', 'true')
    105.     *
    106.     * Decode mixed bar codes
    107.     find_bar_code (Image, SymbolRegions, BarCodeHandle, CodeTypes, DecodedDataStrings)
    108.     *
    109.     * Display decoded data and symbol region
    110.     get_bar_code_result (BarCodeHandle, 'all', 'decoded_types', DecodedDataTypes)
    111.     area_center (SymbolRegions, Area, Rows, Columns)
    112.     for IdxResult := 0 to |DecodedDataStrings|-1 by 1
    113.         if (regexp_test (DecodedDataTypes[IdxResult], 'UPC.*') # 0)
    114.             Color := 'red'
    115.         else
    116.             Color := 'forest green'
    117.         endif
    118.         dev_set_color (Color)
    119.         select_obj (SymbolRegions, SelectedRegion, IdxResult+1)
    120.         dev_display (SelectedRegion)
    121.         disp_message (WindowHandle, DecodedDataTypes[IdxResult]+': '+DecodedDataStrings[IdxResult], 'image', Rows[IdxResult], Columns[IdxResult]-160, Color, 'true')
    122.     endfor
    123.     disp_continue_message (WindowHandle, 'black', 'true')
    124.     stop ()
    125. endfor
    126. *
    127. *
    128. * Now we decode multiple bar code types correctly
    129. *
    130. MixedScanAllExceptRSS_UPC := false
    131. if (MixedScanAllExceptRSS_UPC)
    132.     *
    133.     * We could scan for all bar codes except certain bar code
    134.     * families...
    135.     get_param_info ('find_bar_code', 'CodeType', 'value_list', AllCodeTypes)
    136.     NoRSS := '~'+regexp_select (AllCodeTypes, 'RSS.*')
    137.     NoUPC := '~'+regexp_select (AllCodeTypes, 'UPC.*')
    138.     CodeTypes := ['auto', NoRSS, NoUPC]
    139.     CodeTypesDescription := 'auto, ~RSS*, ~UPC*'
    140. else
    141.     *
    142.     * ...or (as we do here) scan only for the EAN family and
    143.     * Code 39
    144.     get_param_info ('find_bar_code', 'CodeType', 'value_list', AllCodeTypes)
    145.     AllEAN := regexp_select (AllCodeTypes, 'EAN.*')
    146.     CodeTypes := [AllEAN, 'Code 39']
    147.     CodeTypesDescription := 'EAN-13*, EAN-8*, Code 39'
    148. endif
    149. *
    150. * Display information for the user
    151. Message := 'Now we demonstrate the usage of'
    152. Message[1] := 'autodiscrimination to decode multiple'
    153. Message[2] := 'mixed bar code types within one image.'
    154. dev_clear_window ()
    155. disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
    156. disp_continue_message (WindowHandle, 'black', 'true')
    157. stop ()
    158. *
    159. * Demonstrate autodiscrimination for mixed bar code types
    160. for IdxIma := 0 to |ExampleImagesMixed|-1 by 1
    161.     FileName := ExampleImagesMixed[IdxIma]
    162.     read_image (Image, FileName)
    163.     *
    164.     * Display image and description
    165.     get_image_size (Image, Width, Height)
    166.     dev_set_window_extents (-1, -1, Width/2, Height/2)
    167.     dev_display (Image)
    168.     disp_message (WindowHandle, ['Looking for bar code(s) of type:', ' ' + CodeTypesDescription], 'window', 12, 12, 'black', 'true')
    169.     *
    170.     * Decode mixed bar codes
    171.     find_bar_code (Image, SymbolRegions, BarCodeHandle, CodeTypes, DecodedDataStrings)
    172.     *
    173.     * Display decoded data and symbol region
    174.     dev_set_color ('forest green')
    175.     dev_display (SymbolRegions)
    176.     get_bar_code_result (BarCodeHandle, 'all', 'decoded_types', DecodedDataTypes)
    177.     area_center (SymbolRegions, Area, Rows, Columns)
    178.     for IdxResult := 0 to |DecodedDataStrings|-1 by 1
    179.         disp_message (WindowHandle, DecodedDataTypes[IdxResult]+': '+DecodedDataStrings[IdxResult], 'image', Rows[IdxResult], Columns[IdxResult]-160, 'forest green', 'true')
    180.     endfor
    181.     if (IdxIma # |ExampleImagesMixed|-1)
    182.         disp_continue_message (WindowHandle, 'black', 'true')
    183.         stop ()
    184.     endif
    185. endfor
    186. *
    187. * Close the bar code reader
    188. clear_bar_code_model (BarCodeHandle)
    复制代码
    QQ截图20170117095049.png

    1.发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

    2.提问请组织好自己的逻辑,标题注明大概是什么问题,问题内容写详细,需提供问题症状、错误代码、截图、位置等等信息,不要让别人去猜你想问啥;

    3.如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

    4.回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

    该用户从未签到

    3

    主题

    6

    帖子

    532

    积分

    Rank: 3

    积分
    532
     楼主| 发表于 2017-1-18 08:43:12 | 显示全部楼层
    这些都是halcon封装好的接口和调用了,没有原理性的内容呀
    大神们,有原理性的资料么?

    1.发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

    2.提问请组织好自己的逻辑,标题注明大概是什么问题,问题内容写详细,需提供问题症状、错误代码、截图、位置等等信息,不要让别人去猜你想问啥;

    3.如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

    4.回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

  • TA的每日心情
    叹气
    2020-1-17 06:25
  • 签到天数: 7 天

    连续签到: 2 天

    [LV.3]偶尔看看II

    0

    主题

    36

    帖子

    216

    积分

    Rank: 2Rank: 2

    积分
    216
    发表于 2019-9-18 15:31:21 | 显示全部楼层
    關於參考資料可以試試說明中的References
    例如:GS1 General Specifications; Version 12; Issue 1, Jan-2012; GS1.
    希望有所幫助

    1.发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

    2.提问请组织好自己的逻辑,标题注明大概是什么问题,问题内容写详细,需提供问题症状、错误代码、截图、位置等等信息,不要让别人去猜你想问啥;

    3.如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

    4.回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

    您需要登录后才可以回帖 会员登录 | 会员注册

    本版积分规则

    建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站

    51Halcon会员技术交流会员技术交流 | 51Halcon官方客服咨询官方客服咨询 | Halcon切换助手使用反馈切换助手使用

    有问题需要咨询站长?| 申请友链| 小黑屋| 手机版| Archiver|  

    粤ICP备15095995号-2 粤公网安备44030602000670号

    CopyRight © 2015-2020 51Halcon机器视觉. Tencent Cloud X3.4.

    快速回复 返回顶部 返回列表