Halcon尺寸测量相关

1、点到线

projection_pl.hdev,先在线上投影出点,再计算点与投影点的距离。求得点到直线的距离。

2、线、圆、弧

measure_metal_part_first_example.hdev

measure_metal_part.hdev

measure_metal_part_extended.hdev

3、网格

measure_grid.hdev

4、交点

线与线,弧与线

read_image (Image, 'C:/Users/Desktop/1.png')
rgb1_to_gray (Image, Image)
***先找线与线的交点、大拐角的弧与线交点
points_sojka (Image, 9, 2.5, 0.75, 30, 90, 0.5, 'true', Row, Column)
if (Row!=[])
    gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
    dev_display (Image)
    dev_display (Cross)
else
   edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)
   segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 2)
   select_shape_xld (ContoursSplit, SelectedXLD, 'circularity', 'and', 0, 0.02)
***对于弧与线过度比较柔和的,找线的端点作为弧与线的交点
   fit_line_contour_xld (SelectedXLD, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
   get_image_size (Image, Width, Height)
* 获取线段远离边界的那个端点(即趋近于图片中心的点)
if (abs(Height/2-RowBegin)+abs(Width/2-ColBegin)<abs(Height/2-RowEnd)+abs(Width/2-ColEnd))
    gen_cross_contour_xld (Cross, RowBegin, ColBegin, 6, 0.785398)
else
    gen_cross_contour_xld (Cross, RowEnd, ColEnd, 6, 0.785398)
endif
    dev_display (Image)
    dev_display (Cross)
endif

 

posted @ 2020-11-02 09:13  夕西行  阅读(2660)  评论(0编辑  收藏  举报