MATLAB Answers

how can i acess single lens/camera of a stereo camera in matlab?

조회 수: 15(최근 30일)
i have stereo camera with two lens, i want to access each single lens of stereo camera one by one, how can i do that in matlab.? For example, i can seprate the image taken by stereocamera , i.e the image of left lens in one window and the image of right lens in other window, i want to achieve the same in live feed from my camera the live feed command preview only gives a combined feed of both cameras , i want feed of each single lens and then use "handshake" command to combine both feeds and get a 3d image

  댓글 수: 0

로그인 to comment.

채택된 답변

Florian Morsch
Florian Morsch 18 May 2018
If you can take split images for left and right just do that and add them up to your own video stream.
You can run a loop, with every itteration you take a snapshot from the left and right side and then move them to a video player.
For one camera it would be:
%Assign cam
cam = webcam();
% Capture one frame to get its size.
videoFrame = snapshot(cam);
frameSize = size(videoFrame);
% Create the video player object.
videoPlayer = vision.VideoPlayer('Position', [100 100 [frameSize(2), frameSize(1)]+30]);
runLoop = true;
FrameCount = 0;
while runLoop && FrameCount < 100
%Increase FrameCount by 1
FrameCount = FrameCount + 1
%Take a snapshot
videoFrame = snapshot(cam);
%%%Do something here, like make the picture gray
videoFrame = rgb2gray(videoFrame);
%Next frame in the Player
step(videoPlayer, videoFrame);
%Check whether the video player window has been closed.
runLoop = isOpen(videoPlayer);
end
If you say you can take images or snapshots from both cameras you can modify the code so you make two snapshots and use them then. Keep in mind to create a camera object and videoPlayer object for each camera.

  댓글 수: 4

표시 이전 댓글 수: 1
Junaid  Bashir
Junaid Bashir 18 May 2018
Dear sir! my main goal was to find distance from a person using stereovision. now i went through this matlab example "https://www.mathworks.com/help/vision/examples/depth-estimation-from-stereo-video.html" what i am trying to do is to introduce live feed in this example so that i can find distance from a person in live feed using my cameras . . . i made functions for video input objects, as you told in the above answers and tried to use them in this example instead of recorded video files but the matlab gives following error
while the videoobject function runs properly and is as follows
Kindly help me
Florian Morsch
Florian Morsch 18 May 2018
You try to assign the output of the function videoobject to the variable videoFileLeft. The error displayed is "Too many output arguments.", which means the videoobject function wants to load all its outputs into the one variable videoFileLeft. That wont work, you have to check your outputs from videoobject and then assign a variable for each output.
Something like this might work:
[output1, output2, %insert more outputs if you have] = videoobject;
If you create a function you should always assign its input and output arguments, like here: https://de.mathworks.com/help/matlab/ref/function.html
Like that you know whats the input and output, so you can provide the needed variables.
Junaid  Bashir
Junaid Bashir 18 May 2018
yes sir i understand my mistake, but the thing is i am unable to make a function for multiple outputs in this case, i know how to make a multiple output function, but in this case i can't identify what are my outputs , so i am stuck , please help me. the code for this function is as follows
function videoobject
a=webcam(2);
videoframe = snapshot(a);
framesize = size(videoframe);
videoplayer= vision.VideoPlayer('Position', [100 100 [framesize(2), framesize(1)]+30]);
runLoop = true;
FrameCount = 0;
while runLoop && FrameCount < 100
FrameCount = FrameCount + 1
videoframe = snapshot(a);
videoframe = rgb2gray(videoframe);
step(videoplayer, videoframe);
runLoop = isOpen(videoplayer);
end
end
kindly guide me a bit thanks

로그인 to comment.

추가 답변(1개)

Islam Gaied
Islam Gaied 29 Mar 2019
how can i caputres 20 images from 2 cameras left and right for stereo calibration using matlab ?
need script plz

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by