# Depth estimation from live video stream in matlab

I want to estimate depth from live video stream with two calibrated webcams in matlab but has no results. In this post depth is estimated with two recorded video files. how can I estimate depth in live video stream?

## 2 Answers

Since you have two webcams you can reconstruct the video scene using the frame sequence. If your webcams happends to be stereo pair (with known extrinsic parameters aka rotation and translation) your task becomes pretty easy. On the other hand if webcam locations are unknown the problem gets a little trickier, but it can still be solved using matlab's computer vision toolbox. In both of the above cases the scene reconstruction is accurate up to a scale factor. In order to calculate the depth in real units you need length knowlegde about an item in the scene. i.e the edge of a tracked square is 15cm.

You can capture the video from webcams using the Webcam Support Package. Alternatively, you can use the Image Acquisition Toolobx.

• I have this toolbox and package but I don't know how to use live video stream via stereo calibrated webcams against recorded video file. – Rwy5 Feb 9 '16 at 6:46
• Do you know how to capture video frames from a camera? If so, then you would capture a frame from camera 1 and then capture a frame from camera 2, as opposed to reading the frames from video files. – Dima Feb 9 '16 at 16:46
• I think so.the input to function vision.VideoFileReader() is a video file. what is the alternative function to receive a live video stream as input? for example in this post mathworks.com/help/vision/examples/… how can I replace live video stream as input and estimate depth from live video stream? – Rwy5 Feb 10 '16 at 14:00
• If you want to use the Webcam Support Package, then you would need to create to webcam objects and then call the snapshot method on each of them to capture frames. See this example: mathworks.com/help/vision/examples/… – Dima Feb 10 '16 at 14:02