当前位置:网站首页>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
边栏推荐
- Altium designer 19.1.18 - Import frame
- Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
- PIL's image tool image reduction and splicing.
- [professional literacy] core conferences and periodicals in the field of integrated circuits
- RF ride side door processing of prompt box
- How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
- 如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
- Oracle triggers and packages
- Day08 ternary operator extension operator character connector symbol priority
- Record the torch encountered by win10 cuda. is_ False problem in available()
猜你喜欢
C # joint configuration with Halcon
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Drive LED -- GPIO control
Consul安装
研究發現,跨境電商客服系統都有這五點功能!
Ads learning record (lna_atf54143)
Basic embedded concepts
如何进行导电滑环选型
Process communication mode between different hosts -- socket
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
随机推荐
通过sql语句统计特定字段出现次数并排序
How to define guid in AMI code
Altium Designer 19.1.18 - 更改铺铜的透明度
GPIO circuit principle of stm32
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
Win10 shortcut key
Development tools -- gcc compiler usage
Summary of STM32 serial port sending and receiving data methods
How to select conductive slip ring
Global and Chinese market of peeled bourdon tubes 2022-2028: Research Report on technology, participants, trends, market size and share
生产中影响滑环质量的因素
Day09 how to create packages import package naming conventions Alibaba Development Manual
. Net service governance flow limiting middleware -fireflysoft RateLimit
C WinForm [help interface - send email] - practice five
找不到实时聊天软件?给你推荐电商企业都在用的!
Altium designer 19.1.18 - Import frame
Create inf module in AMI code
Query the table name used by kettle in Oracle
RF ride side door processing of prompt box