此示例演示了ECC200读卡器的参数“对比度公差”参数的影响
如果'contrast_tolerance'”设置为“高”,ECC200读卡器对符号内的局部对比度变化更宽容。这是通过内部预处理实现的。如果'contrast_tolerance'设置为“低”,则省略此预处理步骤。如果'contrast_tolerance'设置为“任意”,则读取器会尝试两种模式。请注意,“对比度公差”也包括在ECC200读卡器的训练模式中。
总代码:
*更新状态设为off
dev_update_off ()
*关闭窗口
dev_close_window ()
*
* Initialize image path and window size
*初始化图像路径和窗口大小
*遍历图片
list_image_files ('datacode/ecc200', 'default', [], ImageFiles)
*选择与正则表达式匹配的tuple元素。例如,用于过滤使用操作员列表_文件获得的文件列表。
*'contrast_variations'--“对比变化”
tuple_regexp_select (ImageFiles, 'contrast_variations', ImageFiles)
*读取图片
read_image (Image, ImageFiles[0])
*打开自适应图片的窗口
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('green')
dev_set_line_width (3)
*
* Display short description
*显示简短描述
Message := 'This example program demonstrates how the parameter'
Message[1] := '\'contrast_tolerance\' influences the search with a'
Message[2] := 'ECC200 reader for 2d data code symbols with local'
Message[3] := 'contrast variations.'
*显示信息--该示例程序演示了参数“对比度公差”如何影响ECC200读取器对具有局部对比度变化的二维数据代码符号的搜索。
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Create ECC200 data code model with 'contrast_tolerance' set to 'low'
*创建“对比度公差”设置为“低”的ECC200数据代码模型
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandleLow)
*设置参数为low
set_data_code_2d_param (DataCodeHandleLow, 'contrast_tolerance', 'low')
*
* Create ECC200 data code model with 'contrast_tolerance' set to 'high'
*创建“对比度公差”设置为“高”的ECC200数据代码模型
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandleHigh)
*设置参数为low
set_data_code_2d_param (DataCodeHandleHigh, 'contrast_tolerance', 'high')
*
*对4张图片开始循环
for Index := 0 to 4 by 1
*读取图片
read_image (Image, ImageFiles[Index])
Loops := 2
* Try to find the data code symbol with 'contrast_tolerance' set to 'low'
*尝试查找“对比度公差”设置为“低”的数据代码符号
*计算开始时间
count_seconds (T1)
for Loop := 1 to Loops by 1
*寻找二维码
find_data_code_2d (Image, SymbolXLDs, DataCodeHandleLow, [], [], ResultHandles, DecodedDataStrings)
endfor
*计算结束时间
count_seconds (T2)
FoundLow := |DecodedDataStrings|
TimeLow := 1000 * (T2 - T1) / Loops
*
* Try to find the data code symbol with 'contrast_tolerance' set to 'high'
*尝试查找“对比度公差”设置为“高”的数据代码符号
*计算开始时间
count_seconds (T1)
for Loop := 1 to Loops by 1
find_data_code_2d (Image, SymbolXLDs, DataCodeHandleHigh, [], [], ResultHandles, DecodedDataStrings)
endfor
*计算结束时间
count_seconds (T2)
FoundHigh := |DecodedDataStrings|
TimeHigh := 1000 * (T2 - T1) / Loops
*
* Create message about the search
*创建有关搜索的消息
Color := gen_tuple_const(4,'black')
Message := 'Runtime:'
Message[1] := '\'contrast_tolerance\' = \'low\': ' + TimeLow$'8.2f' + ' ms'
if (FoundLow == 0)
Message[1] := Message[1] + ' (no symbol found)'
Color[1] := 'red'
endif
Message[2] := '\'contrast_tolerance\' = \'high\':' + TimeHigh$'8.2f' + ' ms'
if (FoundHigh == 0)
Message[2] := Message[2] + ' (no symbol found)'
Color[2] := 'red'
endif
*
* Display the data code symbol and information about runtime
*显示数据代码符号和有关运行时的信息
dev_display (Image)
dev_display (SymbolXLDs)
disp_message (WindowHandle, 'Image ' + (Index + 1) + ' of 5', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle, Message, 'window', 40, 12, Color, 'true')
*
* Display continue message
*显示继续消息
if (Index < 5)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endif
endfor
*
* Clear the 2d data code models
*清除二维数据代码模型
clear_data_code_2d_model (DataCodeHandleLow)
clear_data_code_2d_model (DataCodeHandleHigh)
逐段分析:
*更新状态设为off
dev_update_off ()
*关闭窗口
dev_close_window ()
*初始化图像路径和窗口大小
*遍历图片
list_image_files ('datacode/ecc200', 'default', [], ImageFiles)
*选择与正则表达式匹配的tuple元素。例如,用于过滤使用操作员列表_文件获得的文件列表。
*'contrast_variations'--“对比变化”
tuple_regexp_select (ImageFiles, 'contrast_variations', ImageFiles)
*读取图片
read_image (Image, ImageFiles[0])
*打开自适应图片的窗口
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('green')
dev_set_line_width (3)
*显示简短描述
Message := 'This example program demonstrates how the parameter'
Message[1] := '\'contrast_tolerance\' influences the search with a'
Message[2] := 'ECC200 reader for 2d data code symbols with local'
Message[3] := 'contrast variations.'
*显示信息--该示例程序演示了参数“对比度公差”如何影响ECC200读取器
对具有局部对比度变化的二维数据代码符号的搜索。
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*创建“对比度公差”设置为“低”的ECC200数据代码模型
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandleLow)
*设置参数为low
set_data_code_2d_param (DataCodeHandleLow, 'contrast_tolerance', 'low')
*创建“对比度公差”设置为“高”的ECC200数据代码模型
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandleHigh)
*设置参数为low
set_data_code_2d_param (DataCodeHandleHigh, 'contrast_tolerance', 'high')
*对4张图片开始循环
for Index := 0 to 4 by 1
*读取图片
read_image (Image, ImageFiles[Index])
*定义寻找二维码的次数
Loops := 2
*尝试查找“对比度公差”设置为“低”的数据代码符号
*计算开始时间
count_seconds (T1)
for Loop := 1 to Loops by 1
*寻找二维码
find_data_code_2d (Image, SymbolXLDs, DataCodeHandleLow, [], [], ResultHandles, DecodedDataStrings)
endfor
*计算结束时间
count_seconds (T2)
FoundLow := |DecodedDataStrings|
TimeLow := 1000 * (T2 - T1) / Loops
*尝试查找“对比度公差”设置为“高”的数据代码符号
*计算开始时间
count_seconds (T1)
for Loop := 1 to Loops by 1
*寻找二维码
find_data_code_2d (Image, SymbolXLDs, DataCodeHandleHigh, [], [], ResultHandles, DecodedDataStrings)
endfor
*计算结束时间
count_seconds (T2)
*为变量分配新值。
Color := gen_tuple_const(4,'black')
Message := 'Runtime:'
Message[1] := '\'contrast_tolerance\' = \'low\': ' + TimeLow$'8.2f' + ' ms'
if (FoundLow == 0)
Message[1] := Message[1] + ' (no symbol found)'
Color[1] := 'red'
endif
Message[2] := '\'contrast_tolerance\' = \'high\':' + TimeHigh$'8.2f' + ' ms'
if (FoundHigh == 0)
Message[2] := Message[2] + ' (no symbol found)'
Color[2] := 'red'
endif
*显示数据代码符号和有关运行时的信息
dev_display (Image)
dev_display (SymbolXLDs)
disp_message (WindowHandle, 'Image ' + (Index + 1) + ' of 5', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle, Message, 'window', 40, 12, Color, 'true')
*显示继续消息
if (Index < 5)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endif
endfor
*清除二维数据代码模型
clear_data_code_2d_model (DataCodeHandleLow)
clear_data_code_2d_model (DataCodeHandleHigh)