Halcon識別二維碼

一、流程

二、實例

原圖

識別

代碼

* Initialize image path and visual settings
dev_update_off ()
dev_close_window ()
ImageFiles := 'datacode/ecc200/ecc200_cpu_0'
ImageNum := 5
read_image (Image, ImageFiles + '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)
dev_set_color ('green')
* 
* Display short description
Message := 'This simple program demonstrates how to read'
Message[1] := 'ECC 200 data codes in a sequence of images'
Message[2] := 'with the standard default parameter setting.'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Step 1: Create 2d data code model
* ----------------------------------------------------
* Create a 2d data code model of the 2d data code class
* 'Data Matrix ECC 200'. The operator returns a handle to
* the 2d data code model which can be used for all further
* operations on the data code.
create_data_code_2d_model ('Data Matrix ECC 200', [], [], DataCodeHandle)
* 
* Step 2: Read the data codes
* ----------------------------------------------------
* Search and read the data codes in each image and
* display the decoded string for each found data code
for Index := 1 to ImageNum by 1
    read_image (Image, ImageFiles + Index$'.2d')
    find_data_code_2d (Image, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)
    * 
    * Display the results
    dev_display (Image)
    dev_display (SymbolXLDs)
    disp_message (WindowHandle, 'Image ' + Index + ' of ' + ImageNum, 'window', 12, 12, 'black', 'true')
    disp_message (WindowHandle, DecodedDataStrings, 'window', 40, 12, 'black', 'true')
    * 
    * If no data code could be found
    if (|DecodedDataStrings| == 0)
        disp_message (WindowHandle, 'No data code found.\nPlease adjust the parameters.', 'window', 40, 12, 'red', 'true')
    endif
    * 
    * Deactivate the following lines to run the program without breaks
    if (Index < ImageNum)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor
* 
* Clear the 2d data code model
clear_data_code_2d_model (DataCodeHandle)

 

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