当前位置:网站首页>Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
2022-07-05 07:56:00 【BoomBiuBiu】
This routine measures the number of chip pins 、 Average width and pin height
1、 Read the picture
dev_close_window ()
read_image (Image, 'ic_pin')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_display (Image)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
2、 Draw a measuring rectangle
Row := 47
Column := 485
Phi := 0
Length1 := 420
Length2 := 10
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)
*Length1 Length2 Half width and half height
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
* Form a measuring rectangle
gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, 'nearest_neighbor', MeasureHandle)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
3、 Start measurement ---- Show results
* to update PC by off state
dev_update_pc ('off')
* Update variable is off state
dev_update_var ('off')
n := 100
* Calculate start time
count_seconds (Seconds1)
* This cycle is to measure each pin
for i := 1 to n by 1
* Get the measurement results
measure_pairs (Image, MeasureHandle, 1.5, 30, 'negative', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, PinWidth, PinDistance)
endfor
count_seconds (Seconds2)
Time := Seconds2 - Seconds1
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_set_color ('red')
* In order to draw the edge pairs of the detected pins with straight lines
disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond)
* Find the average pin width
avgPinWidth := sum(PinWidth) / |PinWidth|
* Find the average distance between the edge pairs of pins
avgPinDistance := sum(PinDistance) / |PinDistance|
* Find the number of pin edge pairs
numPins := |PinWidth|
dev_set_color ('yellow')
disp_message (WindowHandle, 'Number of pins: ' + numPins, 'image', 200, 100, 'yellow', 'false')
disp_message (WindowHandle, 'Average Pin Width: ' + avgPinWidth, 'image', 260, 100, 'yellow', 'false')
disp_message (WindowHandle, 'Average Pin Distance: ' + avgPinDistance, 'image', 320, 100, 'yellow', 'false')
* dump_window (WindowHandle, 'tiff_rgb', 'C:\\Temp\\pins_result')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
4、 Zoom in on some areas
* Drawing this rectangle is to enlarge this part of the pin image
disp_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
stop ()
dev_set_part (Row1, Column1, Row2, Column2)
dev_display (Image)
dev_set_color ('green')
dev_display (Rectangle)
dev_set_color ('red')
disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
close_measure (MeasureHandle)
5、 Measure the height of the pins
dev_set_part (0, 0, Height - 1, Width - 1)
dev_display (Image)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_set_color ('green')
* draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
Row := 508
Column := 200
Phi := -1.5708
Length1 := 482
Length2 := 35
* Form a rectangular area Measure the pin height
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
* Form a measuring rectangle
gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, 'nearest_neighbor', MeasureHandle)
stop ()
* Measure the distance between the edges
measure_pos (Image, MeasureHandle, 1.5, 30, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
* The height of the upper pin
PinHeight1 := RowEdge[1] - RowEdge[0]
* The height of the following pins
PinHeight2 := RowEdge[3] - RowEdge[2]
dev_set_color ('red')
* Draw a straight line
disp_line (WindowHandle, RowEdge, ColumnEdge - Length2, RowEdge, ColumnEdge + Length2)
disp_message (WindowHandle, 'Pin Height: ' + PinHeight1, 'image', RowEdge[1] + 40, ColumnEdge[1] + 100, 'yellow', 'false')
disp_message (WindowHandle, 'Pin Height: ' + PinHeight2, 'image', RowEdge[3] - 120, ColumnEdge[3] + 100, 'yellow', 'false')
* dump_window (WindowHandle, 'tiff_rgb', 'C:\\Temp\\pins_height_result')
close_measure (MeasureHandle)
dev_set_draw ('fill')
dev_set_line_width (1)
Generate a measurement rectangle
gen_measure_rectangle2( : : Row, Column, Phi, Length1, Length2, Width, Height, Interpolation : MeasureHandle)Row, Column,Phi: Measure the row and column coordinates and angles of the center of the rectangle ;
Length1, Length2: Measure the width and half height of the rectangular plate ;
Width, Height: Measure the width and height of the image where the rectangle is located ;
Interpolation: Interpolation algorithm
MeasureHandle: Handle of measuring rectangle
Find without edge pairs
measure_pos(Image : : MeasureHandle, Sigma, Threshold, Transition, Select : RowEdge, ColumnEdge, Amplitude, Distance)MeasureHandle: Handle of measuring rectangle ;
Sigma: Gaussian smoothing coefficient ;
Threshold: Minimum margin amplitude ;
Transition: excessive , Light to dark ’negative’, Dark to bright ’positive’, Both ’all’
Select : If set to ’all’, All edge points are returned . If you set it to ’ first’, Then only the first of the extracted edge points is returned , Set it to ’last’ when , Return only the last .
RowEdge, ColumnEdge: Row and column coordinates of edge points
Amplitude: Returns the edge amplitude
Distance: Returns the distance between consecutive edges
边栏推荐
- Process communication mode between different hosts -- socket
- Using C language to realize IIC driver in STM32 development
- Shell script basic syntax
- 如何进行导电滑环选型
- Day06 class variables instance variables local variables constant variables naming conventions
- Development tools -- gcc compiler usage
- Function and usage of function pointer
- UEFI development learning 3 - create UEFI program
- UEFI development learning 6 - creation of protocol
- Ten thousand words detailed eight sorting must read (code + dynamic diagram demonstration)
猜你喜欢
Win10 shortcut key
Application of ultra pure water particle counter in electronic semiconductors
Acwing-宠物小精灵之收服-(多维01背包+正序倒序+两种形式dp求答案)
如何进行导电滑环选型
Improve lighting C program
Connection mode - bridge and net
MySQL - storage engine
Makefile application
Numpy——1. Creation of array
C WinForm [change the position of the form after running] - Practical Exercise 4
随机推荐
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
Pointnet++ classification practice
2021-10-28
Record the opening ceremony of Beijing Winter Olympics with display equipment
Shell脚本基本语法
Calibre garbled
Linked list (establishment, deletion, insertion and printing of one-way linked list)
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
Batch modify the txt file code to UTF-8 (notepad++)
Extern keyword function
软件设计师:03-数据库系统
Network communication process
The research found that the cross-border e-commerce customer service system has these five functions!
How to excavate and research ideas from the paper
C WinForm [exit application] - practice 3
Summary of STM32 serial port sending and receiving data methods
Embedded AI intelligent technology liquid particle counter
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
UEFI development learning 2 - running ovmf in QEMU
Cadence simulation encountered "input.scs": can not open input file change path problem