ステレオカメラによる深度測定
18 views (last 30 days)
Show older comments
ステレオカメラによる深度測定を実施しておりますが、
ターゲット画像を読み込んで出力するとピクセル数が下がってしまいます。
これが原因で測定したい範囲が網羅できていないのですが、解決方法を教えてください。
(下記画像のワークスペースを参照ください。)
%ステレオ カメラのパラメーターの読み込み
% Load the stereoParameters object.
load('handshakeStereoParams.mat');
% Visualize camera extrinsics.
showExtrinsics(stereoParams);
%ビデオフレームの読み取りと平行化
frameLeft = imread('I1(left).jpg');
frameRight = imread('I2(right).jpg');
[frameLeftRect, frameRightRect] = ...
rectifyStereoImages(frameLeft, frameRight, stereoParams);
figure;
imshow(stereoAnaglyph(frameLeftRect, frameRightRect));
title('pit_fig');
%視差の計算
frameLeftGray = rgb2gray(frameLeftRect);
frameRightGray = rgb2gray(frameRightRect);
disparityMap = disparity(frameLeftGray, frameRightGray);
figure;
imshow(disparityMap, [0, 100]);
title('Disparity Map');
colormap jet
colorbar
%3次元シーン再構成
points3D = reconstructScene(disparityMap, stereoParams);
% Convert to meters and create a pointCloud object
points3D = points3D ./1000;
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);
![MATLAB.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237529/MATLAB.png)
0 Comments
Accepted Answer
Kenta
on 9 Sep 2019
入力画像のサイズより、キャリブレーション後のサイズが小さくなってしまっている、という意味で正しいでしょうか。
カメラパラメータが原因で、キャリブレーション後のほうが、サイズが小さくなってしまっているのではないでしょうか。カメラパラメータを変えれば、キャリブレーション後の画像サイズも変わると思います。
例えば、
figure;imshow(frameLeftRect)
で、確認した場合、入力画像と似たものが見えると思うのですが、いかがでしょうか。
その場合でも画像の一部が欠損していますか。
13 Comments
Kenta
on 18 Sep 2019
>>やはり原因はこの関数にあるようですが
そのエラーがでるのは、stereoParams.matが現在のパスにないからではないでしょうか。
質問のところでの添付画像で「現在のフォルダー」とありますが、そこに、stereoParames.matをおいて、再度実行いただけますか。
ちなみに、stereoParames.matとhandshakeStereoParames.matのちがいはなんでしょうか。
stereoParames.matは現在お使いのものでとったキャリブレーションファイルではないということでしょうか。
ひとまず、stereoParamesでは全体の画像が出ることを確認いただけると幸いです。
More Answers (0)
See Also
Categories
Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!