Halcon 讀取二維碼和印刷字體內容


嘗試了一下,二維碼可以正確的閱讀,但是閱讀字體的時候,一些字體存在粘連的情況下會閱讀錯誤。

FontName := 'Industrial_0-9A-Z_Rej'

dev_update_window('off')
read_image (Image, 'C:/Image.png')
* rgb轉黑白
rgb1_to_gray (Image, GrayImage)
* 增強圖像
emphasize (GrayImage, ImageEmphasize, 15, 15, 3)
get_image_size (ImageEmphasize, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
*讀取二維碼
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'maximum_recognition', DataCodeHandle)
find_data_code_2d (GrayImage, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)


set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Image)

*創建讀取內容模型
create_text_model_reader('auto','Pharma.omc', TextModel)
*設置模型參數
set_text_model_param (TextModel, 'min_contrast',10)
*查找內容
find_text(ImageEmphasize, TextModel, TextResultID)
*獲取內容
get_text_object (Characters, TextResultID, 'all_lines')

dev_display (Image)
dev_display (SymbolXLDs)
*dev_display(Characters)
disp_message (3600, '二維碼:'+DecodedDataStrings, 'window', 12, 12, 'black', 'true')


get_text_result (TextResultID, 'class', ResultValue)
area_center (Characters, Area, Row, Column)
for index:=0 to |ResultValue| - 1 by 1
    disp_message (WindowHandle, ResultValue[index], 'window', Row[index]-40, Column[index], 'green', 'false')
endfor

clear_text_result (TextResultID)
clear_text_model (TextModel)

 


免責聲明!

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



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