real time image processing using matlab and stereo camera

how do i process each frame of a video feed coming from a pair of stereo camera in matlab in real time?
I have written this code
right = videoinput('winvideo', 1, 'MJPG_640x480');
right1 = getselectedsource(right);
right.FramesPerTrigger = 1;
preview(right);
left = videoinput('winvideo', 2, 'MJPG_640x480');
left2 = getselectedsource(left);
left.FramesPerTrigger = 1;
preview(left);
Thsi fucntion creates two new windows and acquires video from a pair of webcam(stereo) 1 frame by frame.Now how do i do image processing on each frame??
How do i extract each frame of the real time video ,process it and then show the out put in real time in an another video?
I basically want to compute the dispairty map in real time using my disparity algorithm.
So i wud be rectifying and calibrating the images first.
this is my fucntion for rectification and disparity map for a static image/frame
% % Read in the stereo pair of images.
% I1 = imread('leftxy.png');
% I2 = imread('rightxy.png');
function [J1,J2]=calibdisp(stereoParams)
% Rectify the images.
I1=imread('leftxy.png');
I2=imread('rightxy.png');
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams);
% Display the images before rectification.
figure;
imshow(stereoAnaglyph(I1, I2), 'InitialMagnification', 50);
title('Before Rectification');
% Display the images after rectification.
figure;
imshow(stereoAnaglyph(J1, J2), 'InitialMagnification', 50);
title('After Rectification');
how do i apply the same code for each frame of the real time video???

Risposte (2)

Use the getsnapshot method of videoinput to acquire the frame.

3 Commenti

@dima lisin how do i then process the frame and than update the processed data in the live video feed
I am not sure exactly what you mean... Are you asking how to display the processed video? For that you should use vision.VideoPlayer or vision.DeployableVideoPlayer.
@dima lisin this is my code it is wrking but i am facing some problems pls see this http://in.mathworks.com/matlabcentral/answers/231004-real-time-disparity-map-in-matlab

Accedi per commentare.

How did you do to acquire both video ? Do they come from external cameras ? I'm trying to do such a thing but i don't know how to import video's in real time from mutiple cameras.

Categorie

Richiesto:

il 22 Lug 2015

Risposto:

il 13 Giu 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by