Demo entry 6720646

ma

   

Submitted by anonymous on Mar 17, 2018 at 07:47
Language: Matlab. Code size: 2.4 kB.

stereocamera_num=3;
cameraInfo=cell(stereocamera_num, 2);
stereoInfo_internal=cell(stereocamera_num, 1);
stereoInfo_between=cell(stereocamera_num-1, 1);

input_calibvideoobj=VideoReader(inputvideofile);
input_stereocamera_num=stereocamera_num; 
bigcalibframe_width=input_calibvideoobj.Width; 
bigcalibframe_height=input_calibvideoobj.Height;
calibframe_width=bigcalibframe_width / 2;
calibframe_height=bigcalibframe_height / input_stereocamera_num;
actual_calibframenum= input_calibvideoobj.NumberOfFrames;
calibframes=zeros(calibframe_height, calibframe_width, actual_calibframenum, 2, input_stereocamera_num);
for fk=1 : actual_calibframenum
    tempframe=rgb2gray(read(input_calibvideoobj, fk));
    for i=1 : input_stereocamera_num
        calibframes(:, :, fk, 1, i)=tempframe(calibframe_height * (i - 1) + (1 : calibframe_height), 1 : calibframe_width);
        calibframes(:, :, fk, 2, i)=tempframe(calibframe_height * (i - 1) + (1 : calibframe_height),  calibframe_width + (1 : calibframe_width));
    end
end
calib_squaresize = 8;
NumRadialDistortionCoefficients=2;
EstimateTangentialDistortion=false;
for i=1 : input_stereocamera_num
[calib_imagepoints,calib_boardsize,imagepairused]=detectCheckerboardPoints(...
        reshape(calibframes(:, :, :, 1, i ), calibframe_height, calibframe_width, 1, actual_calibframenum), ...
        reshape(calibframes(:, :, :, 2, i ), calibframe_height, calibframe_width, 1, actual_calibframenum));
    calib_worldpoints = generateCheckerboardPoints(calib_boardsize, calib_squaresize);
    [stereoParams, pairsUsed, estimationErrors] = estimateCameraParameters(calib_imagepoints, calib_worldpoints, 'NumRadialDistortionCoefficients' , NumRadialDistortionCoefficients, 'EstimateTangentialDistortion', EstimateTangentialDistortion );
    cameraInfo{i, 1} = stereoParams.CameraParameters1;
    cameraInfo{i, 2} = stereoParams.CameraParameters2;
    stereoInfo_internal{i, 1} = struct('RotationOfCamera', inv(stereoParams.RotationOfCamera2), 'TranslationOfCamera', -stereoParams.TranslationOfCamera2 / stereoParams.RotationOfCamera2, 'FundamentalMatrix', stereoParams.FundamentalMatrix);
    if sum(pairsUsed) < 4
        warning(['#' num2str(i) '号立体相机识别的棋盘标定图像小于4']);
    end
    if stereoParams.MeanReprojectionError > 1
        warning(['#' num2str(i) '号立体相机的立体标定误差较大:' 'MeanReprojectionError=' num2str(stereoParams.MeanReprojectionError)]);
    end
end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).