lioryariv / idr

MIT License
700 stars 85 forks source link

Preprocessing data problem #45

Open FeiiYin opened 1 year ago

FeiiYin commented 1 year ago

Hi, thanks for your awesome work. I intended to use the preprocess_cameras.py to preprocess the custom data, which can be run on threestudio. However, it always raise the bellow error. Can you provide some insights of where to modify?

My input camera is proj_mtx_new, mask is extracted from the alpha of a png. Thanks in advance!

c2w = transform[:3, :4] # transform is a synthesized parameters
mv = torch.linalg.inv(transform)
fovy =  np.random.uniform(self.fovy_range_min, self.fovy_range_max)
self.resolution = [512, 512]
K = np.array([
                [fovy, 0, self.resolution[0] / 2, 0],
                [0, fovy, self.resolution[1] / 2, 0],
                [0, 0, 1, 0],
                [0, 0, 0, 1]
            ])
K = torch.from_numpy(K).float()
proj_mtx_new = K @ mv
Number of points:0
/mnt/petrelfs/wangtengfei/code/NeuS2/tools/preprocess_cameras.py:220: RuntimeWarning: Mean of empty slice.
  centroid = np.array(all_Xs).mean(axis=0)
/opt/conda/lib/python3.9/site-packages/numpy/core/_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)
/opt/conda/lib/python3.9/site-packages/numpy/core/_methods.py:269: RuntimeWarning: Degrees of freedom <= 0 for slice
  ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
/opt/conda/lib/python3.9/site-packages/numpy/core/_methods.py:226: RuntimeWarning: invalid value encountered in divide
  arrmean = um.true_divide(arrmean, div, out=arrmean,
/opt/conda/lib/python3.9/site-packages/numpy/core/_methods.py:261: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)
Traceback (most recent call last):
  File "/mnt/petrelfs/wangtengfei/code/NeuS2/tools/preprocess_cameras.py", line 312, in <module>
    get_normalization(opt.source_dir, opt.use_linear_init, dataset)
  File "/mnt/petrelfs/wangtengfei/code/NeuS2/tools/preprocess_cameras.py", line 266, in get_normalization
    normalization, all_Xs = get_normalization_function(Ps, mask_points_all, number_of_normalization_points, number_of_cameras,masks_all)
  File "/mnt/petrelfs/wangtengfei/code/NeuS2/tools/preprocess_cameras.py", line 225, in get_normalization_function
    centroid,scale,all_Xs = refine_visual_hull(masks_all, Ps, scale, centroid)
  File "/mnt/petrelfs/wangtengfei/code/NeuS2/tools/preprocess_cameras.py", line 151, in refine_visual_hull
    points = points + center[:, np.newaxis]
IndexError: invalid index to scalar variable.
FeiiYin commented 1 year ago

I think I have realized that the coordinate system that I used belongs to the OpenCV, which is quite different from the coordinates systems used in DTU. However, can any guy provide some scripts to transform the coordinates into the DTU format.

skymanaditya1 commented 7 months ago

I have a similar problem. I have the coordinate system in OpenCV camera format. I could look in detail in the paper and see if I can find the desired transformation. But if the authors have it ready, that'd be really useful!