当前位置:网站首页>Halcon blob analysis (ball.hdev)

Halcon blob analysis (ball.hdev)

2022-07-05 08:40:00 Aii parson

* ball.hdev: Inspection of Ball Bonding

dev_update_window ('off')# Stop updating the form
dev_close_window ()# Closing Windows
dev_open_window (0, 0, 728, 512, 'black', WindowID)# create a window , And specify the handle
read_image (Bond, 'die/die_03')
dev_display (Bond)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')

stop ()
threshold (Bond, Bright, 100, 255)# Two valued , Gray histogram tool
shape_trans (Bright, Die, 'rectangle2')# Shape change , Obtain the minimum circumscribed rectangle of the connected domain of a binary graph
dev_set_color ('green')
dev_set_line_width (3)
dev_set_draw ('margin')
# Show edges
dev_display (Die)
disp_continue_message (WindowID, 'black', 'true')
stop ()
reduce_domain (Bond, Die, DieGrey)# Reduced area ( get ROI), amount to Intercept the main parts that need to be studied . Reduce the definition domain of the given image to the specified new area , Does not reduce the actual size of the image , The new area must be a sub area of the original area
threshold (DieGrey, Wires, 0, 50)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
dev_display (Bond)
dev_set_draw ('fill')
# Show fill
dev_set_color ('red')
dev_display (WiresFilled)

disp_continue_message (WindowID, 'black', 'true')
stop ()
opening_circle (WiresFilled, Balls, 15.5)# Reduce pixels , Remove isolated dots 、 Burr and bridge ;Circle It has the greatest effect on the circle .
dev_set_color ('green')
dev_display (Balls)

disp_continue_message (WindowID, 'black', 'true')
stop ()
connection (Balls, SingleBalls)# Disconnect connected domain
select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)# Select the target circle through roundness

// The sorting step can be omitted , Unless you need to display the parameters of some targets ( If only the 2-3 The circumscribed circle diameter of )

sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')# Sort area , Sort by column , First ascending from the left
dev_display (Bond)
dev_set_colored (12)
dev_display (FinalBalls)

disp_continue_message (WindowID, 'black', 'true')
stop ()
smallest_circle (FinalBalls, Row, Column, Radius)# Obtain the minimum circumscribed circle parameter of each region
NumBalls := |Radius|
Diameter := 2 * Radius
meanDiameter := mean(Diameter)
# Omission ( Not quoted later )
minDiameter := min(Diameter)# Omission
dev_display (Bond)# Show the original
disp_circle (WindowID, Row, Column, Radius)# Display circle
dev_set_color ('white')
disp_message (WindowID, 'D: ' + Diameter$'.4', 'image', Row - 2 * Radius, Column, 'white', 'false')# Use image coordinates to display “ The diameter of ” Information
dev_update_window ('on')# Update Form

原网站

版权声明
本文为[Aii parson]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140541151514.html