当前位置:网站首页>Measurement fitting based on Halcon learning -- Practice [2]
Measurement fitting based on Halcon learning -- Practice [2]
2022-06-25 21:34:00 【BoomBiuBiu】
This example measures the length of the workpiece through the measurement assistant 、 Width and diameter of hole
* close window
dev_close_window ()
* Read the picture
read_image (Image, 'C:/Users/gwd/Desktop/ Measure the workpiece .BMP')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width/2, Height/2, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Image)
* Display prompt message
disp_continue_message (WindowHandle, 'black', 'true')
* Measurement assistant
* Measure 01: Code generated by Measure 01
* Measure 01: Prepare measurement
AmplitudeThreshold := 40
RoiWidthLen2 := 27
set_system ('int_zooming', 'true')
* Measure 01: Coordinates for line Measure 01 [0]
LineRowStart_Measure_01_0 := 262.938
LineColumnStart_Measure_01_0 := 85.75
LineRowEnd_Measure_01_0 := 289.188
LineColumnEnd_Measure_01_0 := 978.25
* Measure 01: Convert coordinates to rectangle2 type
TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_0+LineRowEnd_Measure_01_0)
TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_0+LineColumnEnd_Measure_01_0)
TmpCtrl_Dr := LineRowStart_Measure_01_0-LineRowEnd_Measure_01_0
TmpCtrl_Dc := LineColumnEnd_Measure_01_0-LineColumnStart_Measure_01_0
TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
TmpCtrl_Len2 := RoiWidthLen2
* Measure 01: Create measure for line Measure 01 [0]
* Measure 01: Attention: This assumes all images have the same size!
gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 1280, 960, 'nearest_neighbor', MsrHandle_Measure_01_0)
* Measure 01: Coordinates for line Measure 01 [1]
LineRowStart_Measure_01_1 := 172.938
LineColumnStart_Measure_01_1 := 550.75
LineRowEnd_Measure_01_1 := 581.688
LineColumnEnd_Measure_01_1 := 535.75
* Measure 01: Convert coordinates to rectangle2 type
TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_1+LineRowEnd_Measure_01_1)
TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_1+LineColumnEnd_Measure_01_1)
TmpCtrl_Dr := LineRowStart_Measure_01_1-LineRowEnd_Measure_01_1
TmpCtrl_Dc := LineColumnEnd_Measure_01_1-LineColumnStart_Measure_01_1
TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
TmpCtrl_Len2 := RoiWidthLen2
* Measure 01: Create measure for line Measure 01 [1]
* Measure 01: Attention: This assumes all images have the same size!
gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 1280, 960, 'nearest_neighbor', MsrHandle_Measure_01_1)
* Measure 01: Coordinates for line Measure 01 [2]
LineRowStart_Measure_01_2 := 375.438
LineColumnStart_Measure_01_2 := 715.75
LineRowEnd_Measure_01_2 := 381.063
LineColumnEnd_Measure_01_2 := 855.75
* Measure 01: Convert coordinates to rectangle2 type
TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_2+LineRowEnd_Measure_01_2)
TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_2+LineColumnEnd_Measure_01_2)
TmpCtrl_Dr := LineRowStart_Measure_01_2-LineRowEnd_Measure_01_2
TmpCtrl_Dc := LineColumnEnd_Measure_01_2-LineColumnStart_Measure_01_2
TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
TmpCtrl_Len2 := RoiWidthLen2
* Measure 01: Create measure for line Measure 01 [2]
* Measure 01: Attention: This assumes all images have the same size!
gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 1280, 960, 'nearest_neighbor', MsrHandle_Measure_01_2)
* Measure 01: ***************************************************************
* Measure 01: * The code which follows is to be executed once / measurement *
* Measure 01: ***************************************************************
* Measure 01: The image is assumed to be made available in the
* Measure 01: variable last displayed in the graphics window
copy_obj (Image, Image, 1, 1)
* Measure 01: Execute measurements
measure_pairs (Image, MsrHandle_Measure_01_0, 1, AmplitudeThreshold, 'all', 'all', Row1_Measure_01_0, Column1_Measure_01_0, Amplitude1_Measure_01_0, Row2_Measure_01_0, Column2_Measure_01_0, Amplitude2_Measure_01_0, Width_Measure_01_0, Distance_Measure_01_0)
measure_pairs (Image, MsrHandle_Measure_01_1, 1, AmplitudeThreshold, 'all', 'all', Row1_Measure_01_1, Column1_Measure_01_1, Amplitude1_Measure_01_1, Row2_Measure_01_1, Column2_Measure_01_1, Amplitude2_Measure_01_1, Width_Measure_01_1, Distance_Measure_01_1)
measure_pairs (Image, MsrHandle_Measure_01_2, 1, AmplitudeThreshold, 'all', 'all', Row1_Measure_01_2, Column1_Measure_01_2, Amplitude1_Measure_01_2, Row2_Measure_01_2, Column2_Measure_01_2, Amplitude2_Measure_01_2, Width_Measure_01_2, Distance_Measure_01_2)
* Show lines
disp_line (WindowHandle, Row1_Measure_01_0, Column1_Measure_01_0, Row2_Measure_01_0, Column2_Measure_01_0)
disp_line (WindowHandle, Row1_Measure_01_1, Column1_Measure_01_1, Row2_Measure_01_1, Column2_Measure_01_1)
disp_line (WindowHandle, Row1_Measure_01_2, Column1_Measure_01_2, Row2_Measure_01_2, Column2_Measure_01_2)
* Display the results of the measurement
* Long --- Subtract the column of the first edge line from the column of the second edge line
*【 And so on 】
m_width1:=Column2_Measure_01_0-Column1_Measure_01_0
m_width2:=Row2_Measure_01_1-Row1_Measure_01_1
m_width3:=Column2_Measure_01_2-Column1_Measure_01_2
disp_message (WindowHandle, ' Long '+m_width1, 'image', 0, 0, 'red', 'true')
disp_message (WindowHandle, ' wide '+m_width2, 'image', 100, 0, 'red', 'true')
disp_message (WindowHandle, ' The diameter of '+m_width3, 'image', 200, 0, 'red', 'true')
stop ()
* Closing handle
close_measure (MsrHandle_Measure_01_0)
close_measure (MsrHandle_Measure_01_1)
close_measure (MsrHandle_Measure_01_2)
Here are the pictures for the test , If you need to practice, take it from yourself
边栏推荐
- C language dynamic memory allocation
- Docker Alpine image installation PHP extension redis
- PHP runtime and memory consumption statistics code
- Openocd compilation and installation
- js 限制鼠标移动范围
- OLED driven learning based on ssd1306 (II): addressing mode of ssd1306
- couldn‘t be accessed by user ‘_ apt‘
- OLED driver learning based on ssd1306 (I): SSD Chinese command table (handling)
- The SH runtime directly reported an error syntax error near unexpected token ` $'. \r‘
- Compile 6relayd using the cross compiler
猜你喜欢
Type conversion basis
智云健康上市在即:长期亏损,美年健康俞熔已退出,未来难言乐观
How to solve the problem of flash write protection in STM32?
The SH runtime directly reported an error syntax error near unexpected token ` $'. \r‘
How testers write functional test cases
Rounding related calculation
What is a server? (Powercert animated videos)
[important notice] developer document update (12.13-12.19)
lombok
Legal mix of settlements (utf8mb4_0900_ai_ci, implicit) and (utf8mb4_general_ci, implicit) error resolution
随机推荐
05 configuring network parameters
Modprobe: fatal: module kvmgt not found, kvmgt has no module, kvmgt has no driver, gvt-g precautions, gvt-g precautions for starting win10 in UEFI mode
[nailing scenario capability package] exhibition admission
Circular structure and circular keywords
Molecular dynamics - basic characteristics of molecular force field
What is DNS (domain name server)? (Powercert animated videos)
Jmeter- (III) create user test cases for interface testing
The robotframework executes JS commands to move the mouse from X to y
Xshell mouse configuration
PHP compressed file
Send a more awesome website, which can convert curl commands into code in any language
MySQL trigger
Command 'GCC' failed with exit status 1 when PIP install mysqlclient
OBD Position Overview
JS__ Inheritance mode, namespace, object enumeration__ Duyi
Code program related problems troubleshooting directory
银河证券靠谱吗?开证券账户安全吗?
Beginner to embedded development
Differences between modems and routers (powercert animated videos)
ECU test modify test case