欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Example program for distance_pl

程序员文章站 2022-07-04 16:00:26
...

 Example program for distance_pl

dev_close_window ()
read_image (Image, 'mreut')
dev_open_window (0, 0, 512, 512, 'white', WindowID)
dev_display (Image)
dev_set_color ('black')

threshold (Image, Region, 180, 255)

dev_clear_window ()
dev_display (Region)

connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10000, 100000000)
* 访问对象的轮廓(点坐标)
get_region_contour (SelectedRegions, Rows, Columns)

RowLine1 := 5
ColLine1 := 300
RowLine2 := 300
ColLine2 := 400
NumberTuple := |Rows|
dev_set_color ('red')
disp_line (WindowID, RowLine1, ColLine1, RowLine2, ColLine2)

dev_set_color ('green')
for i := 1 to NumberTuple by 20
    * 在这个点上画了一个十字
    disp_line (WindowID, Rows[i], Columns[i] - 2, Rows[i], Columns[i] + 2)
    disp_line (WindowID, Rows[i] - 2, Columns[i], Rows[i] + 2, Columns[i])
    * 计算点线距离
    distance_pl (Rows[i], Columns[i], RowLine1, ColLine1, RowLine2, ColLine2, Distance)
stop()
endfor

 

相关标签: halcon