halcon學習筆記——實例篇(3)條形碼識別



條形碼或條碼(barcode)是由一組按一定編碼規則排列的條,空符號,用以表示一定的字符,數字及符號組成的信息。條碼系統是由條碼符號設計,制作及掃描閱讀組成的自動識別系 統。 條碼卡分為一維碼和二維碼兩種。一維碼比較常用,如日常商品外包裝上的條碼就是一維碼。它的信息存儲量小,僅能存儲一個代號,使用時通過這個代號調 取計算機網絡中的數據。二維碼是近幾年發展起來的,它能在有限的空間內存儲更多的信息,包括文字、圖象、指紋、簽名等,並可脫離計算機使用。

條碼種類很多,常見的大概有二十多種碼制,其中包括:
Code39 碼(標准39碼)、Codabar碼(庫德巴碼)、Code25碼(標准25碼)、ITF25碼(交叉25碼)、Matrix25碼(矩陣25碼)、 UPC-A碼、UPC-E碼、EAN-13碼(EAN-13國際商品條碼)、EAN-8碼(EAN-8國際商品條碼)、中國郵政碼(矩陣25碼的一種變 體)、Code-B碼、MSI碼、Code11碼、Code93碼、ISBN碼、ISSN碼、Code128碼(Code128碼,包括EAN128 碼)、Code39EMS(EMS專用的39碼)等一維條碼和PDF417等二維條碼。


實例3_1:ITF25條形碼識別

ITF25條形碼圖片:

ITF25_1ITF25_2ITF25_3ITF25_4ITF25_5

halcon代碼:

* 讀取ITF25碼
 
create_bar_code_model ([], [], BarCodeHandle)
dev_close_window ()
dev_open_window (0, 0, 120, 300, 'black', WindowHandle)
 
read_image (Image,'D:/MyFile/halcon/條形碼識別/ITF25_1.jpg')
get_image_size (Image, Width, Height)
dev_set_window_extents (0, 0, Width-1, Height-1)
 
set_bar_code_param (BarCodeHandle,'check_char','present')
find_bar_code (Image, SymbolRegions, BarCodeHandle, '2/5 Interleaved', DecodedDataStrings)
disp_message (WindowHandle, DecodedDataStrings, 'window', 18, 12, 'black', 'false')
 
clear_bar_code_model (BarCodeHandle)

實例3_2:Code25條形碼識別

Code25條形碼圖片:

Code25_1Code25_2

halcon代碼:

* 讀取Code25碼
create_bar_code_model ([], [], BarCodeHandle)
dev_close_window ()
dev_open_window (0, 0, 120, 300, 'black', WindowHandle)
 
dev_set_draw ('margin')
dev_set_line_width (3)
 
read_image (Image, 'D:/MyFile/halcon/條形碼識別/Code25_1.jpg')
get_image_size (Image, Width, Height)
dev_set_window_extents (0, 0, Width-1, Height-1)
dev_display (Image)
 
set_bar_code_param (BarCodeHandle, 'check_char','present')
find_bar_code (Image, SymbolRegions, BarCodeHandle, '2/5 Industrial', DecodedDataStrings)
disp_message (WindowHandle, DecodedDataStrings, 'window', 18, 12, 'black', 'false')
 
clear_bar_code_model (BarCodeHandle)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM