Search code examples
3dstereo-3d

Depthmap (Blender) to 3D - What is the baseline


I want to reconstruct a scene from a depthmap using OpenGL. The depthmap is generated using Blender. Now I want to reproject the depthmap to 3D using the following formulas:

Z = focallength *  baseline / depth
X = u*Z / focallength
Y = v*Z / focallength 

u and v are clear and I got the focal length from blenders python API. Now I am stuck with the baseline. The baseline is the length of the distance-vector between the two cameras capturing the scene. In my setup I do not have a 2nd camera. I only got the one blender camera at position (0,1,10).


Solution

  • As far as you are dealing with camera coordinates (depth map's u,v) and the world coordinates ( 3D reconstruction's X,Y,Z) the following equation can be used:

    zc[u,v]'= A [R t] [X,Y,Z]'

    where zc is your depth value at u,v

    A is camera calibration matrix, but obviously (in your equations), you need only information about focal length (as far as you are using ideal pinhole camera in Blender I supose).

    and R,t are the rotation and translation of the world coordinate frame with respect to camera coordinate frame. If you want to have the origin of your new coordinate system in the position of the origin of the camera coordinate system you need to set your depth map camera to (0,0,0) and then you can forget R,t as well.

    As you can see, you dont need any baseline value (set it to 1) in your case. Just use

    zc[u,v,1]' = [f 0 0; 0 f 0; 0 0 1] [X,Y,Z,1]'

    so if I am right your equations should look like:

    X=zc*u/f
    Y=zc*v/f
    Z=zc

    where zc is the depth value.