1. 程式人生 > >halcon讀取二維碼的時候顯示的讀取結果一直閃爍

halcon讀取二維碼的時候顯示的讀取結果一直閃爍

dev_update_off ()
*關閉更新
SequenceName := '1/1.jpg'
open_framegrabber ('DirectShow', 0, 0, 0, 0, -1, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'Integrated Webcam', 0, -1, FGHandle)
*開啟影象獲取裝置並配置  返回FGHandle
grab_image (Image, FGHandle)
*從指定的影象獲取裝置中同步獲取影象 給Image
* grab_image_async (Image, FGHandle, -1
) *從指定的影象獲取裝置中非同步獲取影象 get_image_size (Image, Width, Height) *獲取Image的寬跟高 dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowHandle) *開啟視窗並將影象填充進去 填充位置為 0 0 到width height 返回 WindowHandle set_display_font (WindowHandle, 14, 'courier', 'true', 'false') * 設定字型 * create_bar_code_model([],[],BarCodeHandle) create_data_code_2d_model ('QR Code'
, 'default_parameters', 'maximum_recognition', QRCodeHandle) * create_data_code_2d_model ('Data Matrix ECC 200', [], [], DMCodeHandle) * 建立二維碼模型 碼型別 需要調整的專案 調整的值 返回控制代碼 set_data_code_2d_param (QRCodeHandle, 'default_parameters', 'maximum_recognition') *設定二維碼模型的引數 * set_data_code_2d_param (DataCodeHandle, 'default_parameters'
, 'standard_recognition') while (1) grab_image (Image, FGHandle) * 從裝置中獲取影象 dev_display(Image) *影象更新關閉 dev_update_var ('off') count_seconds (T1) *獲取時間點 * find_bar_code (Image, SymbolRegions, BarCodeHandle, 'auto', DecodedDataStrings3) find_data_code_2d (Image, SymbolXLDs1, QRCodeHandle, 'stop_after_result_num', 2, ResultHandles1, DecodedDataStrings1) * find_data_code_2d (Image , SymbolXLDs2, DMCodeHandle, [], [], ResultHandles2, DecodedDataStrings2) *查詢並讀取二維碼的內容 輸入影象 輸出的輪廓 二維碼模型的處理 處理的引數 處理的資料 成功讀取二維碼的符號 檢測結果 count_seconds (T2) *獲取時間點 dev_update_var ('on') *影象更新開啟 * * display the runtime and the found symbols set_system('filename_encoding','utf8') set_system ('flush_graphic', 'false') *設定halcon的系統引數 重新整理影象 false dev_display (Image) *顯示影象 disp_message (WindowHandle, 'Time = ' + (1000 * (T2 - T1))$'.1f' + 'ms', 'image', 1, 1, 'magenta', 'false') *寫一條文字 左上角顯示用時 dev_set_color ('green') *設定顏色 dev_display (SymbolXLDs1) *顯示二維碼輪廓 for i := 0 to |ResultHandles1| - 1 by 1 *從零到檢測到的二維碼減一個迴圈 每次加一 select_obj (SymbolXLDs1, SymbolXLD1, i + 1) *獲取object tuple中某個值 輸入 輸出 index get_contour_xld (SymbolXLD1, Row, Col) *返回輪廓的座標 輸入輪廓 返回輪廓的行 列 get_string_extents (WindowHandle, DecodedDataStrings1[i], Ascent, Descent, TxtWidth, TxtHeight) *獲取文字的空間的大小 文字 最大高度 最大擴充套件 寬度 高度 TxtCol := min(Col) if (TxtCol + TxtWidth > Width) disp_message (WindowHandle, DecodedDataStrings1[i], 'image', max(Row), max([min(Col) - TxtWidth,1]), 'green', 'false') else disp_message (WindowHandle, DecodedDataStrings1[i], 'image', max(Row), min(Col), 'green', 'false') endif *防止文字超出 endfor set_system ('flush_graphic', 'true') disp_line (WindowHandle, -101, -101, -99, -99) * disp_continue_message (WindowHandle, 'black', 'true') * stop () endwhile close_framegrabber (FGHandle) clear_data_code_2d_model (DataCodeHandle)

今天在學習用halcon二維碼的時候發現讀出來的資料一直閃爍,在對比之前的程式發現,中間有一行添加了一句話
dev_display(Image)
這句話導致視窗中顯示了未處理的圖片,造成顯示的資料閃爍。