資源簡介
* 2D Code generated by Image Acquisition 01 * QR Code dev_close_window () dev_open_window (0, 0, 400, 400, 'black', WindowHandle) *先關閉活動圖形窗口,再打開這個窗口,標識符為WindowHandle; *相對于界面左上角第0行、第0列,大小為400×400像素,顏色為黑色。 open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', 'Gsou USB2.0 Camera', 0, -1, AcqHandle) * 打開幀接收器(圖像采集設備,如攝像頭,工業(yè)相機等),參數(shù)(Parameter)詳見這個算子 * 注意攝像頭的名稱,可以用工具欄中的“助手”——打開新的Image Acquisition獲取攝像頭及插入代碼 grab_image_start (AcqHandle, -1) while (true) grab_image_async (Image, AcqHandle, -1) create_data_code_2d_model ('QR Code', [], [], DataCodeHandle) * 二維碼的創(chuàng)建開頭的算子,clear為結束清除的算子,見下。 set_display_font (WindowHandle, 16, 'mono', 'true', 'false') dev_set_color ('forest green') dev_set_draw ('margin') dev_set_line_width (3) set_data_code_2d_param (DataCodeHandle, 'default_parameters', 'enhanced_recognition') * 設置選定參數(shù)的二維數(shù)據(jù)模型,參數(shù)詳見這個算子 find_data_code_2d (Image, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings) * 檢測和讀取二維代碼符號,也支持讀取二維數(shù)據(jù)模型的序列,參數(shù)詳見這個算子 for i := 0 to |ResultHandles| - 1 by 1 select_obj (SymbolXLDs, SymbolXLD, i 1) get_contour_xld (SymbolXLD, Row, Col) get_string_extents (WindowHandle, DecodedDataStrings, Ascent, Descent, TxtWidth, TxtHeight) disp_message (WindowHandle, DecodedDataStrings, 'image', max(Row-50), max([min(Col 30)-TxtWidth/2,1]), 'black', 'true') endfor *這段for循環(huán)語句的目的是讓解碼到的字符串(二維碼的內容)顯示到二維碼深綠色(forest green上面定義)的解碼區(qū)域框的行列位置。 *disp_message (WindowHandle, DecodedDataStrings, 'window', 12, 12, 'black', 'true') *如果不需要設置顯示到區(qū)域框中間的位置,而是顯示到窗體的上方或其他位置,那么不需要上面那段for語句,只需這段信息顯示的語句即可顯示到窗體相應位置。 if (|DecodedDataStrings|>0) disp_continue_message (WindowHandle, 'black', 'true') stop() endif * if語句,當解碼一個(大于0,可設置多個)二維碼就暫停攝像頭獲取圖像,直至按F5. clear_data_code_2d_model (DataCodeHandle) endwhile close_framegrabber (AcqHandle)
代碼片段和文件信息
- 上一篇:wpf gridsplit 布局
- 下一篇:C# 雙色球
評論
共有 條評論