当前位置:网站首页>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
边栏推荐
- A complete set of indicators for the 10000 class clean room of electronic semiconductors
- Altium Designer 19.1.18 - 隐藏某一个网络的飞线
- Programming knowledge -- basis of C language
- assert_ Usage of param function
- Record the opening ceremony of Beijing Winter Olympics with display equipment
- Network communication model -- Network OSI tcp/ip layering
- Good websites need to be read carefully
- C WinForm [get file path -- traverse folder pictures] - practical exercise 6
- Some tips for using source insight (solve the problem of selecting all)
- solver. Learning notes of prototxt file parameters
猜你喜欢
Ads usage skills
Acwing-宠物小精灵之收服-(多维01背包+正序倒序+两种形式dp求答案)
High end electronic chips help upgrade traditional oil particle monitoring
Scm-05 basis of independent keyboard
Application of ultra pure water particle counter in electronic semiconductors
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Ads learning record (lna_atf54143)
Oracle triggers and packages
Numpy——1.數組的創建
Embedded composition and route
随机推荐
Altium Designer 19.1.18 - 导入板框
研究發現,跨境電商客服系統都有這五點功能!
Distinction between heap and stack
Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody
A simple method to prove 1/t Fourier transform
1-stm32 operation environment construction
Ads usage skills
PIL's image tool image reduction and splicing.
.NET服务治理之限流中间件-FireflySoft.RateLimit
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
Network communication process
A complete set of indicators for the 10000 class clean room of electronic semiconductors
The printer encountered an abnormal configuration problem 0x8007007e (win10)
Some errors in configuring the environment
Openxlsx field reading problem
Altium Designer 19.1.18 - 更改铺铜的透明度
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
Altium designer learning (I)
Create inf module in AMI code
Global and Chinese market of peeled bourdon tubes 2022-2028: Research Report on technology, participants, trends, market size and share