收藏 分享(赏)

Halcon 通過xld檢測貼片.doc

上传人:青山 文档编号:8684839 上传时间:2022-10-12 格式:DOC 页数:3 大小:22.50KB
下载 相关 举报
Halcon 通過xld檢測貼片.doc_第1页
第1页 / 共3页
Halcon 通過xld檢測貼片.doc_第2页
第2页 / 共3页
Halcon 通過xld檢測貼片.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、Halcon 通過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_off ()* For visualization purposes, we spe

2、cify 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_window ()dev_open_window (0, 0, Width, Heigh

3、t, 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, 50,100,100,50,50, 50,50,150,150,50, 6,6,

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

5、-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) count_seconds (S1) find_aniso_shape_model

6、 (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_tposition (WindowHandle, 10, 10) write_str

7、ing (WindowHandle, Num$d+ models found in +Time$5.2f+ ms) MeanColumn := mean(Column)*找出工件,並計算出工件與模板的關系 for I := 0 to Num-1 by 1 * Display the found model. hom_mat2d_identity (HomMat2D) *二維描述矩陣,就是一個三維單位矩陣。 hom_mat2d_scale (HomMat2D, ScaleRI, ScaleCI, 0, 0, HomMat2D) *為一個同質二維變換矩陣添加一個縮放(輸入矩陣,縮放因子,固定點,結

8、果矩陣) hom_mat2d_rotate (HomMat2D, AngleI, 0, 0, HomMat2D) *為一個同質二維變換矩陣添加一個循環(輸入矩陣,旋轉角度,固定點,輸出矩陣) hom_mat2d_translate (HomMat2D, RowI, ColumnI, HomMat2D) *為一個同質二維變換矩陣添加一個轉換 affine_trans_contour_xld (ModelContours, ContoursTrans, HomMat2D) *仿射轉換。 dev_display (ContoursTrans) * Display the models scale n

9、ext 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_TRUE) Button := 0 endifendwhileclear_shape_model (ModelID)* Reset the number of significant bits of uint2 images to unknown.set_system (int2_bits, -1)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 网络技术 > 软件架构

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:文库网官方知乎号:文库网

经营许可证编号: 粤ICP备2021046453号世界地图

文库网官网©版权所有2025营业执照举报