一、流程
二、实例
原图
识别
代码:
* Read bar codes of type 2/5 Industrial
*
create_bar_code_model ([], [], BarCodeHandle)
* We expect to decode a single bar code per image
set_bar_code_param (BarCodeHandle, 'stop_after_result_num', 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', 'present')
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
clear_bar_code_model (BarCodeHandle)