我想从立体摄像机创建一个3D地图,为了测试这个,我使用两个给定的matlab示例:
-
https://de.mathworks.com/help/vision/ref/estimatecameraparameters.html
(立体摄像机校准)
-
https://de.mathworks.com/help/vision/examples/depth-estimation-from-stereo-video.html
我将这两个脚本组合成以下脚本:
% load left and right images
leftImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
'calibration','stereo','left'));
rightImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
'calibration','stereo','right'));
% calculate image points
[imagePoints,boardSize] = ...
detectCheckerboardPoints(leftImages.Files,rightImages.Files);
% calculate world points
squareSize = 108;
worldPoints = generateCheckerboardPoints(boardSize,squareSize);
% calculate camera paramters
I = readimage(leftImages,1);
imageSize = [size(I,1),size(I,2)];
stereoParams = estimateCameraParameters(imagePoints,worldPoints, ...
'ImageSize',imageSize);
% get left and right image
frameLeftGray = imread(leftImages.Files{1});
frameRightGray = imread(rightImages.Files{1});
[frameLeftRect, frameRightRect] = ...
rectifyStereoImages(frameLeftGray, frameRightGray, stereoParams);
% get disparity map
disparityMap = disparity(frameLeftRect, frameRightRect);
figure;
imshow(disparityMap, [0, 128]);
title('Disparity Map');
colormap jet
colorbar
% create 3D Bar
points3D = reconstructScene(disparityMap, stereoParams);
% Convert to meters and create a pointCloud object
points3D = points3D ./ 1000;
% This will fail
ptCloud = pointCloud(points3D, 'Color', frameLeftRect);
% Create a streaming point cloud viewer
player3D = pcplayer([-3, 3], [-3, 3], [0, 8], 'VerticalAxis', 'y', ...
'VerticalAxisDir', 'down');
% Visualize the point cloud
view(player3D, ptCloud);
但是,执行i的upoon将收到以下错误消息:
使用pointcloud/set时出错。颜色(第545行)“颜色”必须对应于
输入点的数目。
点云错误(第151行)
这个颜色=C;
卸载(第45行)ptcloud=pointcloud(points3d)时出错,
“颜色”,frameleftrect);
当分别尝试示例1)和2)时,它们工作得很好。我认为这与图像大小本身有关。无论调整大小如何,都会导致错误的相机参数。
那么,是否有其他方法来修复存在“color”参数的错误?
提前谢谢你