本例显示了条形码参数的使用:方向和全部方向
总代码:
*创建条形码阅读器
create_bar_code_model ([], [], BarCodeHandle)
* 设置参数--最小黑条或者白条的像素为1.5
set_bar_code_param (BarCodeHandle, 'element_size_min', 1.5)
*
* Initialization
*初始化
dev_update_off ()
dev_close_window ()
*读取图片
read_image (Image, 'barcode/25interleaved/25interleaved16')
*打开自适应图片的窗口
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
*显示图片
dev_display (Image)
dev_set_draw ('margin')
dev_set_line_width (3)
dev_set_color ('green')
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
*
* Read all barcodes with default parameters
*读取带有默认参数的所有条形码
get_bar_code_param (BarCodeHandle, 'orientation', InputOrient)
get_bar_code_param (BarCodeHandle, 'orientation_tol', InputOrientTol)
Mode := 'Default orientation'
*找到带有方向的条形码
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Restrict search to 0 - 20 deg
* Only 1 code will be found
*将搜索限制在0-20度,只会找到一个代码
InputOrient := 10
InputOrientTol := 10
Mode := 'Restricted orientation'
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Restrict search to 90 - 110 deg
* Only the other code will be found
*将搜索限制在90-110度,只会找到其他代码
InputOrient := 100
InputOrientTol := 10
Mode := 'Restricted orientation'
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
*
* Close Barcode reader
clear_bar_code_model (BarCodeHandle)
逐段分析:
*创建条形码阅读器
create_bar_code_model ([], [], BarCodeHandle)
* 设置参数--最小黑条或者白条的像素为1.5
set_bar_code_param (BarCodeHandle, 'element_size_min', 1.5)
*初始化
dev_update_off ()
dev_close_window ()
*读取图片
read_image (Image, 'barcode/25interleaved/25interleaved16')
*打开自适应图片的窗口
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
*显示图片
dev_display (Image)
dev_set_draw ('margin')
dev_set_line_width (3)
dev_set_color ('green')
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
*读取带有默认参数的所有条形码
get_bar_code_param (BarCodeHandle, 'orientation', InputOrient)
get_bar_code_param (BarCodeHandle, 'orientation_tol', InputOrientTol)
Mode := 'Default orientation'
*找到带有方向的条形码
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
*显示信息
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*将搜索限制在0-20度,只会找到一个代码
InputOrient := 10
InputOrientTol := 10
Mode := 'Restricted orientation'
*寻找条形码
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
*显示信息
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*将搜索限制在90-110度,只会找到其他代码
InputOrient := 100
InputOrientTol := 10
Mode := 'Restricted orientation'
*寻找条形码
find_oriented_bar_code (Image, BarCodeHandle, Mode, InputOrient, InputOrientTol, WindowHandle)
*释放条形码阅读器分配的内存
clear_bar_code_model (BarCodeHandle)