halcon 激光三角

一、简介

前两天面试,人家问到了激光三角,之前我还自己搭建过,但是今天却想不起来,知识是要复习的

二、分类与原理

1、正入射

2、斜射入

 

calibrate_sheet_of_light_calplate.hdev  案例

Reconstruct_Connection_Rod_Calib.hdev

三、大致流程

 

 


dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowID)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
dev_display (Angio)
disp_message (WindowID, 'Original image', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID, 'black', 'true')
stop ()
calculate_lines_gauss_parameters (8, [12,0], Sigma, Low, High)
lines_gauss (Angio, Lines, Sigma, Low, High, 'light', 'true', 'parabolic', 'true')
lines_color (Angio, Lines1, 1.5, 3, 8, 'true', 'true')
lines_facet (Angio, Lines2, 5, 3, 8, 'light')
select_contours_xld (Lines, RelLines, 'length', 5.0, 999, 0, 0)
dev_set_colored (12)
dev_display (Angio)
dev_display (RelLines)
disp_message (WindowID, 'Extracted lines', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID, 'black', 'true')
stop ()
count_obj (RelLines, Number)
sort_contours_xld (RelLines, RelLines, 'lower_left', 'true', 'row')
gen_empty_obj (PrintedLines)
for I := 1 to Number by 1
    dev_display (Angio)
    dev_set_color ('white')
    dev_display (PrintedLines)
    select_obj (RelLines, Line, I)
    dev_set_color ('green')
    dev_display (Line)
    concat_obj (PrintedLines, Line, PrintedLines)
    get_contour_xld (Line, Row, Col)
    meanRow := sum(Row) / |Row|
    meanCol := sum(Col) / |Col|
    get_contour_attrib_xld (Line, 'width_left', WidthL)
    get_contour_attrib_xld (Line, 'width_right', WidthR)
    get_contour_attrib_xld (Line, 'contrast', Contrast)
    meanContrast := sum(Contrast) / |Contrast|
    * To display the lines widths, the point at which the gray value drops
    * to 25% of the contrast between the line and the background will be
    * displayed.  This point is given by sqrt(3/4) for the parabolic line
    * model.
    Diameter := (WidthL + WidthR) * sqrt(0.75)
    Diam := sum(Diameter) / |Diameter|
    if (meanRow > Height - 50)
        disp_message (WindowID, 'diam: ' + Diam, 'image', Height - 70, meanCol, 'yellow', 'false')
    else
        disp_message (WindowID, 'diam: ' + Diam, 'image', meanRow, meanCol, 'yellow', 'false')
    endif
    disp_message (WindowID, 'Diameters of line segments', 'window', 135, 60, 'black', 'true')
    if (I < 5)
        disp_continue_message (WindowID, 'black', 'true')
        stop ()
    else
        wait_seconds (0.2)
    endif
endfor
dev_update_on ()

猜你喜欢

转载自blog.csdn.net/weixin_39354845/article/details/123030755