当前位置:网站首页>Measurement fitting based on Halcon learning [i] fuse Hdev routine
Measurement fitting based on Halcon learning [i] fuse Hdev routine
2022-07-05 07:56:00 【BoomBiuBiu】
This routine measures the width of the fuse
First step : Get photo
* Close the update of the window when the program is executing
dev_update_window ('off')
* close window
dev_close_window ()
* First step : Get photo
read_image (Fuse, 'fuse')
get_image_size (Fuse, Width, Height)
dev_open_window_fit_image (Fuse, 0, 0, Width, Height, WindowID)
set_display_font (WindowID, 12, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_display (Fuse)
set_display_font (WindowID, 12, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop () 
The second step : Create a measurement object
* The second step : Create a measurement object
* Appoint ROI
Row := 297
Column := 545
Length1 := 80
Length2 := 10
Angle := rad(90)
gen_rectangle2 (ROI, Row, Column, Angle, Length1, Length2)
* Generate a measurement rectangle
gen_measure_rectangle2 (Row, Column, Angle, Length1, Length2, Width, Height, 'bilinear', MeasureHandle)
dev_display (ROI)
disp_continue_message (WindowID, 'black', 'true')
stop ()
* Extract edge pairs
measure_pairs (Fuse, MeasureHandle, 1, 1, 'negative', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
disp_continue_message (WindowID, 'black', 'true')
stop ()

The third step : Show results
* The third step : Show results
for i := 0 to |RowEdgeFirst| - 1 by 1
* Draw two straight lines
gen_contour_polygon_xld (EdgeFirst, [-sin(Angle + rad(90)) * Length2 + RowEdgeFirst[i],-sin(Angle - rad(90)) * Length2 + RowEdgeFirst[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeFirst[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeFirst[i]])
gen_contour_polygon_xld (EdgeSecond, [-sin(Angle + rad(90)) * Length2 + RowEdgeSecond[i],-sin(Angle - rad(90)) * Length2 + RowEdgeSecond[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeSecond[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeSecond[i]])
* Set the color of the first line
dev_set_color ('cyan')
dev_display (EdgeFirst)
* Set the color of the second line
dev_set_color ('magenta')
dev_display (EdgeSecond)
dev_set_color ('blue')
* Control the position of font display
if (i == 0)
set_tposition (WindowID, RowEdgeFirst[i] + 5, ColumnEdgeFirst[i] + 20)
else
set_tposition (WindowID, RowEdgeFirst[i] - 40, ColumnEdgeFirst[i] + 20)
endif
* Display the distance on the image
write_string (WindowID, 'width: ' + IntraDistance[i] + ' pix')
endfor
disp_continue_message (WindowID, 'black', 'true')
stop ()
* Delete the measurement object
close_measure (MeasureHandle)
dev_update_window ('on')
dev_clear_window ()
Two important operators :
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 with edge pairs
measure_pairs(Image : : MeasureHandle, Sigma, Threshold, Transition, Select : RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)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 .
RowEdgeFirst, ColumnEdgeFirst,AmplitudeFirst: Row and column coordinates and edge amplitude of the first edge center
RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond: Row and column coordinates and edge amplitude of the second edge center
IntraDistance: Returns the distance between two edges in the edge alignment
Distance: Returns the distance between two consecutive edge pairs
边栏推荐
- Altium designer 19.1.18 - clear information generated by measuring distance
- C # joint configuration with Halcon
- Factors affecting the quality of slip rings in production
- Rename directory in C [closed] - renaming a directory in C [closed]
- Shell脚本基本语法
- MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
- Distinction between heap and stack
- GPIO circuit principle of stm32
- Create inf module in AMI code
- [popular science] some interesting things that I don't know whether they are useful or not
猜你喜欢

如何进行导电滑环选型

The research found that the cross-border e-commerce customer service system has these five functions!

Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody

Altium designer 19.1.18 - clear information generated by measuring distance

Network port usage

Nombre - 1. Création de tableaux
![C WinForm [display real-time time in the status bar] - practical exercise 1](/img/9f/d193cbb488542cc4c439efd79c4963.jpg)
C WinForm [display real-time time in the status bar] - practical exercise 1
![C WinForm [get file path -- traverse folder pictures] - practical exercise 6](/img/8b/1e470de4e4ecd4fd1bb8e5cf23f466.jpg)
C WinForm [get file path -- traverse folder pictures] - practical exercise 6

Embedded composition and route

C language enhancement -- pointer
随机推荐
Practical application cases of digital Twins - fans
Ten thousand words detailed eight sorting must read (code + dynamic diagram demonstration)
Altium designer 19.1.18 - hide the fly line of a network
Realization of binary relation of discrete mathematics with C language and its properties
RTOS in the development of STM32 single chip microcomputer
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
Numpy——1.數組的創建
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
Using C language to realize IIC driver in STM32 development
Summary of STM32 serial port sending and receiving data methods
The browser cannot access Baidu
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Train your dataset with yolov4
Day09 how to create packages import package naming conventions Alibaba Development Manual
Threads and processes
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
A series of problems in offline installation of automated test environment (ride)
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
QT excellent articles
如何进行导电滑环选型