基于Halcon学习的一维码识别【十四】ean13addon.hdev

读取EAN-13 Add-On 5型条形码


总代码:

*读取EAN-13 Add-On 5型条形码
create_bar_code_model ([], [], BarCodeHandle)
dev_close_window ()
dev_open_window (0, 0, 120, 300, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)
set_bar_code_param (BarCodeHandle, 'element_size_min', 1.5)
set_bar_code_param (BarCodeHandle, 'element_size_max', 16)
read_image (Image, 'barcode/ean13addon5/ean13addon501')
dev_resize_window_fit_image (Image, 0, 0, -1, -1)
find_bar_code (Image, SymbolRegions, BarCodeHandle, 'EAN-13 Add-On 5', DecodedDataStrings)
area_center (SymbolRegions, Area, Row, Column)
dev_display (Image)
dev_display (SymbolRegions)
disp_message (WindowHandle, DecodedDataStrings, 'image', Row - 30, Column - 90, 'black', 'true')
clear_bar_code_model (BarCodeHandle)

逐段分析:

*创建模板
create_bar_code_model ([], [], BarCodeHandle)
dev_close_window ()
dev_open_window (0, 0, 120, 300, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)

*设置条形码的最小的像素
set_bar_code_param (BarCodeHandle, 'element_size_min', 1.5)

*设置条形码的最大的像素
set_bar_code_param (BarCodeHandle, 'element_size_max', 16)

*读取图片
read_image (Image, 'barcode/ean13addon5/ean13addon501')

基于Halcon学习的一维码识别【十四】ean13addon.hdev

*设置窗口的大小与图片的大小相适应
dev_resize_window_fit_image (Image, 0, 0, -1, -1)

*寻找条形码
find_bar_code (Image, SymbolRegions, BarCodeHandle, 'EAN-13 Add-On 5', DecodedDataStrings)

*获得区域的行列坐标
area_center (SymbolRegions, Area, Row, Column)
dev_display (Image)
dev_display (SymbolRegions)

*显示结果
disp_message (WindowHandle, DecodedDataStrings, 'image', Row - 30, Column - 90, 'black', 'true')
clear_bar_code_model (BarCodeHandle)

基于Halcon学习的一维码识别【十四】ean13addon.hdev

 

上一篇:python set(集合)


下一篇:Creating .deb to install bash script program