1.caltab_points( : : CalTabDescrFile : X, Y, Z)
从标定文件中读取标定板坐标系中的标定点坐标
2.binocular_calibration( : : NX, NY, NZ, NRow1, NCol1, NRow2, NCol2, StartCamParam1, StartCamParam2, NStartPose1, NStartPose2, EstimateParams : CamParam1, CamParam2, NFinalPose1, NFinalPose2, RelPose, Errors)
计算立体视觉系统的所有参数
参数:
NX, NY, NZ:标定点坐标数组;
NRow1, NCol1, NRow2, NCol2:标定点的图像坐标数组;
StartCamParam1, StartCamParam2:相机1,2的初始内参数;
NStartPose1, NStartPose2:标定板在相机1,2的初始位姿;
EstimateParams:选择将被计算的相机参数;
CamParam1, CamParam2:计算得到的相机1,2的内参数;
NFinalPose1, NFinalPose2:所有标定模型在摄像机坐标系中的位姿数组;
RelPose:相机2相对于相机1的位姿;
Errors:像素距离的平均错位率;
3.check_epipolar_constraint(ImageRectifiedL, ImageRectifiedR : : RectCamParL, RectCamParR, WindowHandle1, WindowHandle2 : EpipolarError)
内部程序,检查并显示极线约束
4.gen_binocular_rectification_map( : Map1, Map2 : CamParam1, CamParam2, RelPose, SubSampling, Method, MapType : CamParamRect1, CamParamRect2, CamPoseRect1, CamPoseRect2, RelPoseRect) 产生变换映射,该映射描述了左右相机对到图像校正后的基平面之间的映射。
参数:
MapL, MapR:包含左右目相机映射数据的映射图。
CamParamL, CamParamR:两相机的原始参数。
RelPose:右目相对于左目的位姿。
SubSampling: 相机的二次采样因数。
Method:图像校正方法。
MapType: 映射的插值方式。
CamParamRect1, CamParamRect2: 相机图像矫正后的内外参数
CamPoseRect1, CamPoseRect2:校正前的相机在校正后相机坐标系中的位姿态
RelPoseRect:矫正后的相机2相对于相机1的位姿。
5.find_marks_and_pose(Image, CalTabRegion : : CalTabDescrFile, StartCamParam, StartThresh, DeltaThresh, MinThresh, Alpha, MinContLength, MaxDiamMarks : RCoord, CCoord, StartPose)
从图像中抽取标定点,计算标定板在摄像机坐标系中的位姿。
控制参数:
CalTabDescrFile:标定板描述文件
StartCamParam:照相机的内参数
StartThresh :检测轮廓时的初始阈值。
DeltaThresh:检测失败时下一次比前一次减小的阈值。
MinThresh:检测循环时终止的阈值。
Alpha:边缘检测时的滤波参数,值越小平滑效果越好,但细节越模糊。
MinContLength:标定点轮廓的最小长度,小于此长度的轮廓将被去除。
MaxDiamMarks:标定点的最大直径,大于此直径的椭圆区域将被去除。
RCoord, CCoord:标定点中心坐标。
StartPose:标定板坐标系在摄像机坐标系下的位姿。
* Application program to demonstrate the calibration of a binocular stereo system. * * We have a stereo setup of two cameras ('camera1 is left of camera2'). * Both cameras will be calibrated by a couple of images of a 30mm calibration plate. An image pair * will be rectified to epipolar images and the epipolar constraint will be checked. * --------------------------------------------------------- * Set the image path ImgPath := 'stereo/board/' * Read the first images to get their size Index := 1 read_image (ImageL, ImgPath+'calib_l_'+Index$'02d') read_image (ImageR, ImgPath+'calib_r_'+Index$'02d') * Reopen the windows with an appropriate size dev_close_window () get_image_size (ImageL, WidthL, HeightL) dev_open_window (0, 0, WidthL, HeightL, 'black', WindowHandle1) dev_set_draw ('margin') dev_set_color ('green') dev_update_window ('off') set_display_font (WindowHandle1, 14, 'mono', 'true', 'false') get_image_size (ImageR, WidthR, HeightR) dev_open_window (0, WidthL+5, WidthL, HeightL, 'black', WindowHandle2) dev_set_draw ('margin') dev_set_color ('green') dev_update_window ('off') * Read the model calibration points. CaltabFile := 'caltab_30mm.descr' caltab_points (CaltabFile, X, Y, Z) //从标定板文件中读取标定点坐标// * Set the initial values for the interior camera parameters StartCamParL := [0.0125, 0, 1.48e-5, 1.48e-5,WidthL/2.0,HeightL/2.0,WidthL,HeightL] StartCamParR := StartCamParL * Parameter settings for find_caltab and find_marks_and_pose SizeGauss := 3 MarkThresh := 120 MinDiamMarks := 5 StartThresh := 128 DeltaThresh := 10 MinThresh := 18 Alpha := 0.9 MinContLength := 15 MaxDiamMarks := 100 * Create the tuples in which the image coordinates of the * calibration marks and the initial poses will be accumulated * dev_update_window ('off') RowsL := [] ColsL := [] StartPosesL := [] RowsR := [] ColsR := [] StartPosesR := [] * Start the loop over the calibration images for Index := 1 to 15 by 1 * Read the calibration images read_image (ImageL, ImgPath+'calib_l_'+Index$'02d') read_image (ImageR, ImgPath+'calib_r_'+Index$'02d') * Search for the calibration plate find_caltab (ImageL, CaltabL, CaltabFile, SizeGauss, MarkThresh, MinDiamMarks) find_caltab (ImageR, CaltabR, CaltabFile, SizeGauss, MarkThresh, MinDiamMarks) * Display calibration plate regions dev_set_window (WindowHandle1) dev_display (ImageL) dev_display (CaltabL) dev_set_window (WindowHandle2) dev_display (ImageR) dev_display (CaltabR) * Extraction of marks and pose as well as visualization of the * results for the second image. find_marks_and_pose (ImageL, CaltabL, 'caltab_30mm.descr', StartCamParL, StartThresh, DeltaThresh, MinThresh, Alpha, MinContLength, MaxDiamMarks, RCoordL, CCoordL, StartPoseL) disp_caltab (WindowHandle1, CaltabFile, StartCamParL, StartPoseL, 1) * Extraction of marks and pose as well as visualization of the * results for the second image. find_marks_and_pose (ImageR, CaltabR, 'caltab_30mm.descr', StartCamParR, StartThresh, DeltaThresh, MinThresh, Alpha, MinContLength, MaxDiamMarks, RCoordR, CCoordR, StartPoseR) disp_caltab (WindowHandle2, CaltabFile, StartCamParR, StartPoseR, 1) * Accumulate the image coordinates of the calibration marks * as well as the estimated initial poses for all stereo pairs, * where the poses has been estimated consistently. RowsL := [RowsL,RCoordL] ColsL := [ColsL,CCoordL] StartPosesL := [StartPosesL,StartPoseL] RowsR := [RowsR,RCoordR] ColsR := [ColsR,CCoordR] StartPosesR := [StartPosesR,StartPoseR] endfor * Perform the actual calibration binocular_calibration (X, Y, Z, RowsL, ColsL, RowsR, ColsR, StartCamParL, StartCamParR, StartPosesL, StartPosesR, 'all', CamParamL, CamParamR, NFinalPoseL, NFinalPoseR, cLPcR, Errors) * If required, save the results to disk: * write_cam_par (CamParamL, 'cam_left-125.dat') * write_cam_par (CamParamR, 'cam_right-125.dat') * write_pose (cLPcR, 'pos_right2left.dat') * Generate the rectification maps gen_binocular_rectification_map (MapL, MapR, CamParamL, CamParamR, cLPcR, 1, 'geometric', 'bilinear', RectCamParL, RectCamParR, CamPoseRectL, CamPoseRectR, RectLPosRectR) * Read in a stereo image pair, aquired with the stereo camera system, * which has been calibrated, just now. read_image (ImageL, ImgPath+'calib_l_01') read_image (ImageR, ImgPath+'calib_r_01') * Rectify the stereo images and display them map_image (ImageL, MapL, ImageRectifiedL) map_image (ImageR, MapR, ImageRectifiedR) * Check the epipolar constraint on the rectified images, * (the differences of the features' row coordinates should be small) * and visualize the result (including some corresponding epipolar lines) check_epipolar_constraint (ImageRectifiedL, ImageRectifiedR, RectCamParL, RectCamParR, WindowHandle1, WindowHandle2, EpipolarError)
|