目录
1、create_bar_code_model ([], [], BarCodeHandle)
2、set_bar_code_param (BarCodeHandle, 'stop_after_result_num', 1)
3、set_bar_code_param_specific (BarCodeHandle, '2/5 Industrial', 'min_code_length', 1)
4、dev_set_window_extents (0, 0, Width - 1, Height - 1)
5、find_bar_code (Image, SymbolRegions, BarCodeHandle, '2/5 Industrial', DecodedDataStrings)
一、程序源码分析
*创建条形码模型句柄
create_bar_code_model ([], [], BarCodeHandle)
*设置参数:对每张图像解码一个条码
set_bar_code_param (BarCodeHandle, 'stop_after_result_num', 1)*有些代码显示最小码长为1位。因此,我们需要减少这个应用程序的默认设置
*注意,在实际应用程序中不建议这样做,因为可能会出现更多的错误读取。
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')
*取条形码,结果字符串包含检查字符(不使用校验码)
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 ()
*使用检查字符读取条形码以检查结果,即检查字符不再属于返回的字符串,如果校验字符不正确,则读取条码失败
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
二、相关算子
1、create_bar_code_model ([], [], BarCodeHandle)
原型: