Hi Angelyn,
Actually I planned to cover this question in upcoming second part of my "
StereoPi Fisheye robot" article. I will do it later, but most of the code you need already published in my
Github repo.
Key points for you:
1. Connecting the real world with the calculated world
First step for "connecting" virtual world, calculated from video frames, is correct settings of a square size on a chessboard at the moment of camera calibration.
For example, in this calibration script "
4_calibration_fisheye.py" you can find this code:
Code: Select all
# Chessboard parameters
rows = 6
columns = 9
square_size = 2.5
You need to set adequate square size for correct calculations in the future. You can find a lot of this question discussions, like
this one.
2. Depth map is not a distance
Depth map is actually a disparity between two points on a left and right images. For calculating real distance you can use a simple trigonometry calculations. Luckily, OpenCV has a special function for this, which recalculate disparity map to the real-world 3D coordinates X, Y and Z for each image point. This is "reprojectImageTo3D" function.
3. Code example
Actually I've already uploaded 7th script called "
7_2d_map.py" to my repo, but not yet commented it.
To say briefly, we take a middle horisontal part of 3D map, choose the closest points to the camera, reconstruct it in 3D, equalize Z coordinates and get 2D obstacles map for indoor robot. As I understand, you do not need this approach, and can just use "reprojectImageTo3D" directly.
After calibration and 3D reconstruction you can use some object at, say, 2 meters from the camera, to calibrate your actual measurements.
One more notice: "front" direction in 3D reconstructed world is not coinciding with the "front" direction of your stereocamera. You will find this in your experiments.
p.s. Stereomaton, you've posted your answer while I was writing my.

You are right about calculations, and, as I mentioned, this feature is implemented in OpenCV. Also focal length is calculated automatically while calibration procedure.