Halcon視覺distance_pp-@龍熙視覺培訓

  • Calculate the distance between two points

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)
    RowPoint := 80
    ColPoint := 250
    NumberTuple := |Rows|
    dev_set_color (‘red’)
    dev_set_draw (‘margin’)
  • Display a circle that represented one point
    gen_circle (Circle, RowPoint, ColPoint, 10)
    dev_display (Circle)
    dev_set_color (‘green’)
  • Calculate the distance between points of the contour
  • of the selected region and the displayed point
    for I := 1 to NumberTuple by 10
    gen_cross_contour_xld (Cross, Rows[I], Columns[I], 6, 0.785398)
    gen_contour_polygon_xld (Contour, [Rows[I],RowPoint], [Columns[I],ColPoint])
    dev_set_color (‘green’)
    dev_display (Cross)
    dev_set_color (‘white’)
    dev_display (Contour)
    distance_pp (RowPoint, ColPoint, Rows[I], Columns[I], Distance)
    wait_seconds (0.02)

在這裏插入圖片描述

endfor

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章