Halcon Example - 圓弧測量對象的使用


在 measure_arc.hdev 示例的基礎上,修改優化,並添加注釋

read_image (Zeiss1, 'zeiss1')
get_image_size (Zeiss1, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_display (Zeiss1)
* disp_continue_message (WindowHandle, 'black', 'true')
* stop ()

* 弧線圓心
Row := 275
Column := 335
* disp_cross (WindowHandle, Row, Column, 6, 0)
* 弧線半徑
Radius := 107
* disp_circle (WindowHandle, Row, Column, Radius)
* 弧線起點和終點
AngleStart := -rad(55)
AngleExtent := rad(170)

dev_set_draw ('fill')
dev_set_color ('green')
dev_set_line_width (1)
* draw_ellipse (WindowHandle, Row, Column, Phi, Radius1, Radius2)
get_points_ellipse (AngleStart + AngleExtent, Row, Column, 0, Radius, Radius, RowPoint, ColPoint)
disp_arc (WindowHandle, Row, Column, AngleExtent, RowPoint, ColPoint)
dev_set_line_width (3)

* 准備用於提取垂直於環形弧的直邊的測量對象
* CenterRow (input_control)  Row coordinate of the center of the arc.
* CenterCol (input_control)  Column coordinate of the center of the arc.
* Radius (input_control)  Radius of the arc.
* AngleStart (input_control)  Start angle of the arc in radians.
* AngleExtent (input_control)  Angular extent of the arc in radians.
* AnnulusRadius (input_control)  Radius (half width) of the annulus.
* Width (input_control)  Width of the image to be processed subsequently.
* Height (input_control)  Height of the image to be processed subsequently.
* Interpolation (input_control)  Type of interpolation to be used.
* MeasureHandle (output_control)  Measure object handle.
gen_measure_arc (Row, Column, Radius, AngleStart, AngleExtent, 10, Width, Height, 'nearest_neighbor', MeasureHandle)
count_seconds (Seconds1)
* 提取垂直於矩形或環形弧的直邊
* Image (input_object)  輸入圖像
* MeasureHandle (input_control)  測量對象句柄
* Sigma (input_control)  高斯平滑系數
* Threshold (input_control)  最小邊緣幅度
* Transition (input_control)  Light/dark 或者 dark/light 邊緣
* Select (input_control)  選擇終點
* RowEdge (output_control)  Row coordinate of the center of the edge
* ColumnEdge (output_control)  Column coordinate of the center of the edge
* Amplitude (output_control)  邊緣的邊緣幅度(帶符號)
* Distance (output_control)  連續邊緣之間的距離
measure_pos (Zeiss1, MeasureHandle, 1, 10, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
count_seconds (Seconds2)
Time := Seconds2 - Seconds1

* 計算第二點到第三點之間的距離
distance_pp (RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2], IntermedDist)
dev_set_color ('blue')
disp_cross (WindowHandle, RowEdge, ColumnEdge, 6, 0)
dev_set_color ('red')
disp_line (WindowHandle, RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2])
dev_set_color ('yellow')
disp_message (WindowHandle, 'Distance: ' + IntermedDist, 'image', -1, -1, 'yellow', 'false')
* 釋放測量對象
close_measure (MeasureHandle)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM