OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sat, 04 Apr 2020 11:09:11 -0500Finding depth of an object using 2 camerashttp://answers.opencv.org/question/228501/finding-depth-of-an-object-using-2-cameras/Hi,
I am new to stereo imaging and learning to find depth of an object.
I have 2 cameras kept separately looking at a cardboard surface.
**Given** :
- 8 points marked on the cardboard surface.
- Captured one image each from both the camera.
- Identified (x,y) coordinates of all 8 points in both the images.
**Problem** : Find the depth of each point i.e. distance of each point from the cameras.
*I tried solving it using following approach but I got weird result* :
1. Noted down 8 common points from both the left and right images captured from 2 different cameras.
2. Determined Fundamental Matrix between both the images using 8 points.
3. The fundamental matrix F relates the points on the image plane of one camera in image coordinates (pixels) to the points on the image plane of the other camera in image coordinates
- Opencv Function : cv::findFundamentalMat()
- Input to the function : 8 common points from both the image
- Output = Fundamental matrix of 3x3
4. Performed stereo rectification
- It reprojects the image planes of our two cameras so that they reside in the exact same plane, with image rows perfectly aligned into a frontal parallel configuration.
- Opencv Function : cv::stereoRectifyUncalibrated()
- Input to the function : 8 common Points from the images and fundamental matrix
- Output = Rectification matrices H1 and H2 for both the images.
5. Determined depth of a point
- Trying to find the depth of a point which is aprox. 39 feet (468 inches) away from the camera.
- Formula to find depth is Z = (f * T) / (xl – xr)
- Z is depth, f is focal lenth, T is distance between camera, xl and xr are x coordinate of a point on left image and right image respectively.
- Following are the values taken for the variables :
- f = From the determined camera intrinsic of the camera, I got fx and fy. So I found out f = sqrt(fx*fx + fy*fy)
- T = 2 cameras are kept apart 36 feet i.e. 432 inches. So, I gave T = 432
- xl and xr are x values of the point from left and right images which are perspective transformed using rectification matrices H1 and H2.
- But I got very weird result.
You can look at the screenshot of my experimentation and result.
![image description](/upfiles/158601511677758.png)
So could someone tell me the approach I am taking is right or wrong ?cvsolverSat, 04 Apr 2020 11:09:11 -0500http://answers.opencv.org/question/228501/Stereo - Depth Range Calculationhttp://answers.opencv.org/question/175620/stereo-depth-range-calculation/How to know the depth range of the Stereo camera?
**Camera Specifications**
* Baseline : 6 cm.
* FOV : 120°(D)
* Focal Length: 2.8 mm
* Sensor Size: 1/3 inch
* Resolution: 640 x 480 (from each sensor)
**Calibration procedure:**
* Fisheye module of OpenCV3.1 to calibrate both the camera's individually.
* Proceeded by Stereo Calibration.
* Matching Algorithm Used: StereoBM
**Observations:**
* Depth Range - 30 cm to 100 cm.
* The RMS error for the individual camera calibration and stereo calibration is less than 0.5.
* The depth value in the range (30 cm - 100 cm) is pretty good, i.e i don't get much deviation in the depth.
**Question:**
Is this is the maximum range for the above specifications.John_OpenCVdevTue, 03 Oct 2017 08:29:55 -0500http://answers.opencv.org/question/175620/