Halcon 通過xld檢測貼片_第1頁
Halcon 通過xld檢測貼片_第2頁
Halcon 通過xld檢測貼片_第3頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、HYPERLINK /rocky69/article/details/7247381Halcon 通過xld檢測貼片 * This example program shows how to use HALCONs shape-based matching* to find SMD capacitors that exhibit independent size changes in the row and* column direction in images with a depth of 10 bits (i.e., in images of type uint2).dev_update_

2、off ()* For visualization purposes, we specify the number of significant bits in the uint2* images. We do this because this information cannot be stored in the image* files themselves.set_system (int2_bits, 10)read_image (Image, smd/smd_capacitors_01)get_image_size (Image, Width, Height)dev_close_wi

3、ndow ()dev_open_window (0, 0, Width, Height, black, WindowHandle)dev_set_color (green)dev_set_line_width (3)set_display_font (WindowHandle, 16, mono, true, false)* Create a synthetic model for the SMD capacitors. This is just a rectangle* with rounded corners.gen_contour_polygon_rounded_xld (Contour

4、, 50,100,100,50,50, 50,50,150,150,50, 6,6,6,6,6, 0.01)*根據(jù)一個多邊形(polygon)(以元組形式給出)的圓形角點創(chuàng)建一個XLD輪廓(contour)*((輸出)結(jié)果輪廓,多邊形的行列坐標,多邊形的圓角半徑,采樣距離)gen_image_const (Image, byte, 200, 150)*創(chuàng)建一個固定灰度值的圖像(輸出圖像,像素類型,圖像寬,高)paint_xld (Contour, Image, ImageModel, 128)*把XLD目標畫在一個圖像中(要繪制到圖像去的XLD輪廓,圖像,結(jié)果圖像,xld輪廓期望的灰度值)cr

5、eate_aniso_shape_model (ImageModel, auto, -rad(10), rad(20), auto, 0.9, 1.7, auto, 0.9, 1.1, auto, none, use_polarity, auto, 20, ModelID)*get_shape_model_contours (ModelContours, ModelID, 1)*Button := 0ImgNo := 1while (Button # 1) read_image (Image, smd/smd_capacitors_+ImgNo$02d) dev_display (Image)

6、 count_seconds (S1) find_aniso_shape_model (Image, ModelID, -rad(10), rad(20), 0.9, 1.7, 0.9, 1.1, 0.7, 0, 0.5, least_squares, 0, 0.8, Row, Column, Angle, ScaleR, ScaleC, Score) count_seconds (S2) Time := (S2-S1)*1000 Num := |Score| * Display the number of found models and the recognition time. set_

7、tposition (WindowHandle, 10, 10) write_string (WindowHandle, Num$d+ models found in +Time$5.2f+ ms) MeanColumn := mean(Column)*找出工件,並計算出工件與模板的關(guān)系 for I := 0 to Num-1 by 1 * Display the found model. hom_mat2d_identity (HomMat2D) *二維描述矩陣,就是一個三維單位矩陣。 hom_mat2d_scale (HomMat2D, ScaleRI, ScaleCI, 0, 0, Ho

8、mMat2D) *為一個同質(zhì)二維變換矩陣添加一個縮放(輸入矩陣,縮放因子,固定點,結(jié)果矩陣) hom_mat2d_rotate (HomMat2D, AngleI, 0, 0, HomMat2D) *為一個同質(zhì)二維變換矩陣添加一個循環(huán)(輸入矩陣,旋轉(zhuǎn)角度,固定點,輸出矩陣) hom_mat2d_translate (HomMat2D, RowI, ColumnI, HomMat2D) *為一個同質(zhì)二維變換矩陣添加一個轉(zhuǎn)換 affine_trans_contour_xld (ModelContours, ContoursTrans, HomMat2D) *仿射轉(zhuǎn)換。 dev_display (C

9、ontoursTrans) * Display the models scale next to the found model. ScaleRowStr := ScaleRow=+ScaleRI$5.3f ScaleColStr := ScaleCol=+ScaleCI$5.3f get_string_extents (WindowHandle, ScaleRowStr, AscentStr, DescentStr, WidthStr, HeightStr) *獲取一個字符串的空間大?。ù翱诰浔紤]的變量,往上的最大高度,往下的最大延伸,文本寬,文本高) if (ColumnI 4) ImgNo := 1 endif dev_error_var (Error, 1) dev_set_check (give_error) get_mposition (WindowHandle, R, C, Button) dev_error_var (Error, 0) dev_set_check (give_error) if (Error#H_MSG

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論