TRI-ML / packnet-sfm

TRI-ML Monocular Depth Estimation Repository
https://tri-ml.github.io/packnet-sfm/
MIT License
1.23k stars 242 forks source link

point cloud from NRS pretrained model #200

Open Alvin0629 opened 2 years ago

Alvin0629 commented 2 years ago

Hi,

I am using your pretrained model on the image from OmniCam dataset, the input and output inverse depth are here. 000000252 000000252 However, when I want to try to get the point cloud using 'reconstruct()' function in camera_generic.py as:

 def reconstruct(depth, frame='c'):
    """
    Reconstructs pixel-wise 3D points from a depth map: P(x, y) = s(x, y) + d(x, y) * r(x, y)
    Parameters
    ----------
    depth : torch.Tensor [B,1,H,W]
        Depth map for the camera
    frame : 'w'
        Reference frame: 'c' for camera and 'w' for world
    Returns
    -------
    points : torch.tensor [B,3,H,W]
        Pixel-wise 3D points
    """

    H, W = depth.shape

    Xc = Rmat * (1.0 / depth)        #1.0 / depth to convert inverse depth to depth

    # If in camera frame of reference
    if frame == 'c':
        return Xc

and

canonical_ray_surface = torch.tensor(
            np.load("omnicam_ray_template.npy"))

coeff = np.min([((100.0*0.0)**(4/3.) / 100.), 1.])
Rmat = canonical_ray_surface
Rmat = Rmat / torch.norm(Rmat, dim=1, keepdim=True)

The output point cloud is wrong like this, where could be the problem? Thanks!!! image