Halco自标定
作者:互联网
*1. 算法功能:径向畸变自校正*2. 算法思路:* (1)检测含直线轮廓XLD* (2)矫正畸变图像
*---------初始化,读图------------
dev_update_off ()
read_image (Image, 'board/board-01')
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Image)
disp_message (WindowHandle, 'Image with radial distortions', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*----------------(1)检测直线轮廓XLD=----------------
* i 利用canny滤波器提取图像边缘
edges_sub_pix (Image, Edges, 'canny', 1, 10, 40)
* ii 分割直线段以及圆弧线段
segment_contours_xld (Edges, SplitEdges, 'lines_circles', 5, 4, 2)
* iii 选择足够长的线段用于自标定
select_shape_xld (SplitEdges, SelectedEdges, 'contlength', 'and', 30, 100000)
dev_display (Image)
dev_set_colored (12)
dev_display (SelectedEdges)
disp_message (WindowHandle, 'Extracted edges', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
disp_message (WindowHandle, 'Performing self-calibration...', 'window', 0, 0, 'black', 'true')
*----------------(2)矫正畸变图像=----------------
* i 相机自标定,根据边缘求取内参
radial_distortion_self_calibration (SelectedEdges, CalibrationEdges, 646, 492, 0.08, 42, 'division', 'variable', 0, CamParSingleImage)
* ii 获取无畸变相机内参
get_domain (Image, Domain)
change_radial_distortion_cam_par ('fixed', CamParSingleImage, 0, CamParSingleImageRect)
* iii 根据内参,进行图像畸变矫正
change_radial_distortion_image (Image, Domain, ImageRectified, CamParSingleImage, CamParSingleImageRect)
*-----------结果显示------------
*显示原始图像XLD以及用于矫正图像所需的直线段
dev_display (Image)
dev_display (CalibrationEdges)
disp_message (WindowHandle, 'Edges used for calibration', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*显示矫正图像
dev_display (ImageRectified)
disp_message (WindowHandle, 'Image without radial distortions', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
标签:disp,Halco,Image,标定,dev,black,true,WindowHandle 来源: https://blog.csdn.net/qq_36689119/article/details/95318432