def disparity_to_depth(disparity, camera, invalid_value=0.0):
    """ Calculate depth map from disparity map. Depth values smaller than 0.0
	    and larger than max_depth are set to invalid_value.
    """

    depth = (camera.fx * camera.baseline) / (disparity - camera.doff)
    depth[depth < 0] = invalid_value
    depth[depth > camera.max_depth] = invalid_value
    return depth