基于Halcon学习的二维码识别【六】pdf417_bottle.hdev
生活随笔
收集整理的這篇文章主要介紹了
基于Halcon学习的二维码识别【六】pdf417_bottle.hdev
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本程序演示如何讀取PDF 417類型的二維數據代碼。
總代碼:
*更新狀態設為off dev_update_off () dev_close_window () *讀取圖片 read_image (Image, 'datacode/pdf417/pdf417_bottle_01')*打開自適應圖片的窗口 dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle) set_display_font (WindowHandle, 16, 'mono', 'true', 'false') dev_set_line_width (3)*畫一個矩形 gen_rectangle1 (Rectangle, 250, 0, 600, 610) dev_set_color ('green') * * Create a 2d data code model *創建二維數據代碼模型 create_data_code_2d_model ('PDF417', [], [], DataCodeHandle) *設置參數'maximum_recognition'--“最大認可度” set_data_code_2d_param (DataCodeHandle, 'default_parameters', 'maximum_recognition') * *定義圖片的數量 NumImages := 6 for Index := 1 to NumImages by 1* Read the image and decode the 2d data code*讀取圖片read_image (Image, 'datacode/pdf417/pdf417_bottle_' + Index$'02')reduce_domain (Image, Rectangle, ImageReduced)*計算開始時間count_seconds (T1)*尋找二維碼find_data_code_2d (ImageReduced, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)*計算結束時間count_seconds (T2)Time := 1000 * (T2 - T1)* * Display the runtime and the found symbols*顯示運行時和找到的符號dev_set_window (WindowHandle)dev_display (Image)dev_display (SymbolXLDs)*顯示信息disp_message (WindowHandle, 'Data code found in ' + Time$'.1f' + ' ms', 'window', 12, 12, 'black', 'true')for I := 1 to |ResultHandles| by 1Length := strlen(DecodedDataStrings[I - 1])Message := ['Value:',DecodedDataStrings[I - 1]{0:(Length / 2) - 1},DecodedDataStrings[I - 1]{Length / 2:Length - 1}]disp_message (WindowHandle, Message, 'image', (I + 1) * 24, 12, 'black', 'true')endforif (Index != NumImages)disp_continue_message (WindowHandle, 'black', 'true')stop ()endif endfor * *清除二維數據代碼模型 clear_data_code_2d_model (DataCodeHandle)逐段分析:
*更新狀態設為off dev_update_off () dev_close_window ()*讀取圖片 read_image (Image, 'datacode/pdf417/pdf417_bottle_01')*打開自適應圖片的窗口 dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle) set_display_font (WindowHandle, 16, 'mono', 'true', 'false') dev_set_line_width (3)*畫一個矩形 gen_rectangle1 (Rectangle, 250, 0, 600, 610) dev_set_color ('green')*創建二維數據代碼模型 create_data_code_2d_model ('PDF417', [], [], DataCodeHandle)*設置參數'maximum_recognition'--“最大認可度” set_data_code_2d_param (DataCodeHandle, 'default_parameters', 'maximum_recognition') * *定義圖片的數量 NumImages := 6 for Index := 1 to NumImages by 1*讀取圖片read_image (Image, 'datacode/pdf417/pdf417_bottle_' + Index$'02')reduce_domain (Image, Rectangle, ImageReduced) *計算開始時間count_seconds (T1)*尋找二維碼find_data_code_2d (ImageReduced, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)*計算結束時間count_seconds (T2)Time := 1000 * (T2 - T1)*顯示運行時和找到的符號dev_set_window (WindowHandle)dev_display (Image)dev_display (SymbolXLDs)*顯示信息disp_message (WindowHandle, 'Data code found in ' + Time$'.1f' + ' ms', 'window', 12, 12, 'black', 'true') for I := 1 to |ResultHandles| by 1Length := strlen(DecodedDataStrings[I - 1])Message := ['Value:',DecodedDataStrings[I - 1]{0:(Length / 2) - 1},DecodedDataStrings[I - 1]{Length / 2:Length - 1}]*顯示信息disp_message (WindowHandle, Message, 'image', (I + 1) * 24, 12, 'black', 'true')endforif (Index != NumImages)disp_continue_message (WindowHandle, 'black', 'true')stop ()endif endfor*清除二維數據代碼模型 clear_data_code_2d_model (DataCodeHandle)?
總結
以上是生活随笔為你收集整理的基于Halcon学习的二维码识别【六】pdf417_bottle.hdev的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java笔记08-Map详解
- 下一篇: 前后端分离项目如何部署_前后端分离项目,