Halcon 讀取工業條形碼

上圖:
在這裏插入圖片描述

貼上代碼:

* 讀取2/5類型工業條形碼
create_bar_code_model ([], [], BarCodeHandle)
*檢測一張圖片上的單一條形碼
set_bar_code_param (BarCodeHandle, 'stop_after_result_num', 1)

* Some codes show a minimal code length of 1 digit. Hence, we need to decrease the
* default setting for this application.
set_bar_code_param_specific (BarCodeHandle, '2/5 Industrial', 'min_code_length', 1)
*關閉窗口
dev_close_window ()
*重新打開一個窗口
dev_open_window (0, 0, 120, 300, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
for I := 1 to 4 by 1
    read_image (Image, 'barcode/25industrial/25industrial0' + I)
    get_image_size (Image, Width, Height)
    dev_set_window_extents (0, 0, Width - 1, Height - 1)
    dev_display (Image)
    dev_set_color ('green')
    * Read bar code, the resulting string includes the check character
    set_bar_code_param (BarCodeHandle, 'check_char', 'absent')
    find_bar_code (Image, SymbolRegions, BarCodeHandle, '2/5 Industrial', DecodedDataStrings)
    disp_message (WindowHandle, DecodedDataStrings, 'window', 12, 12, 'black', 'false')
    LastChar := strlen(DecodedDataStrings) - 1
    disp_message (WindowHandle, sum(gen_tuple_const(LastChar,' ')) + DecodedDataStrings{LastChar}, 'window', 12, 12, 'forest green', 'false')
    stop ()
    * Read bar code using the check character to check the result, i.e.,
    * the check character does not belong to the returned string anymore.
    * If the check character is not correct, the bar code reading fails
    dev_set_color ('green')
    set_bar_code_param (BarCodeHandle, 'check_char', 'present')
    find_bar_code (Image, SymbolRegions, BarCodeHandle, '2/5 Industrial', DecodedDataStrings)
    disp_message (WindowHandle, DecodedDataStrings, 'window', 36, 12, 'black', 'false')
    dev_set_color ('magenta')
    if (I < 4)
        stop ()
    endif
endfor

算子回顧

find_bar_code 檢測並讀取圖像中的條形碼符號

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章