dev_open_window (0, 0, Width/2, Height/2, ’black’, WindowID) mean_image (WoodPiece1, ImageMean, 9, 9) dyn_threshold (WoodPiece1, ImageMean, Regions, 5.0, ’dark’) threshold (WoodPiece1, Dark, 0, 90)
dilation_rectangle1 (Dark, DarkDilation, 30, 7) difference (Regions, DarkDilation, RegionBright) connection (RegionBright, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions,
’area’, ’and’, 30, 10000000)
get_mbutton (WindowID, Row1, Column1, Button1) get_mbutton (WindowID, Row2, Button2) intersection (Line, SelectedRegions, Inters) connection (Inters, ConnectedInters) Number := |ConnectedInters|
5 焊接
文件名:ball.dev
这是第一个涉及质量检测的例子。这个例子用来检测焊点。图5.9展示了两种典型的虚焊。
图5.9 虚焊图形
虚焊的边界和连接线看起来是暗的。这样你可以使用门限。因为背景也是黑的,我们要先提取虚焊在作分割之前。虚焊是明亮的,我们可以通过灰度来选择它们的像素。