def rectified_disparity_to_depth(fx, B, disparity):
    """Convert a rectified disparity map to depthmap.

    Assumes left/right cameras are rectified.

    fx: Horizontal camera focal length (batch, 1, rows, cols).
    B: Baseline between the left and right camers (batch, 1, rows, cols)
    """
    eps = 1e-7
    depthmap = fx * B / (disparity + eps)
    return depthmap