您的位置:首页 > 其它

find_pads.hdev例程相关学习

2015-07-18 14:40 239 查看
index:.../Applications/Positon-Recognition-2D/find_pads.hdev

应用范围-二维位置定位




* This example program shows how to find pads in an image and how to

* determine their position, rotation, and size robustly and accurately using

* fit_rectangle2_contour_xld.

dev_update_pc ('off')

dev_update_window ('off')

dev_update_var ('off')

read_image (Image, 'die_pads')

dev_close_window ()

get_image_size (Image, Width, Height)

dev_open_window (0, 0, Width * 2, Height * 2, 'black', WindowHandle)

dev_set_part (0, 0, Height - 1, Width - 1)

* Find the pads in the image using blob analysis.

fast_threshold (Image, Region, 180, 255, 20)

connection (Region, ConnectedRegions)

select_shape (ConnectedRegions, SelectedRegions, ['area','anisometry'], 'and', [200,1], [1200,2])

* Construct a ROI for subpixel-accurate edge detection.

fill_up (SelectedRegions, RegionFillUp)

shape_trans (RegionFillUp, RegionTrans, 'convex')

boundary (RegionTrans, RegionBorder, 'inner')

dilation_circle (RegionBorder, RegionDilation, 2.5)

union1 (RegionDilation, RegionUnion)

固定流程,fillup--shapetrans(conve凸)--取内边缘--膨胀--合体1

* Perform the subpixel-accurate edge detection.

reduce_domain (Image, RegionUnion, ImageReduced)

edges_sub_pix (ImageReduced, Edges, 'sobel_fast', 0.5, 20, 40)

在提取的只有pads边框那一胖圈的地方提取边缘 edges

* Select the edge fragments that belong to the pads.

select_shape_xld (Edges, SelectedContours, 'contlength', 'and', 10, 200)

'contlength':Total length of contour (see length_xld)

* Merge adjacent edge fragments to obtain one contour per pad.

union_adjacent_contours_xld (SelectedContours, UnionContours, 2, 1, 'attr_keep')

* Fit rectangles robustly to the pads' edges.

fit_rectangle2_contour_xld (UnionContours, 'tukey', -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder)

* Generate rectangles from the fitting result for visualization purposes.

gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)

dev_display (Image)

dev_set_colored (12)

dev_display (Rectangle)

在稳定实现功能后,开始注意代码规范,不然不值26万円給料。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: