kunkun0w0 / clean-torch-nerfs Goto Github PK
View Code? Open in Web Editor NEWClean NeRFs Reproduction using Tiny Lego
Clean NeRFs Reproduction using Tiny Lego
ref_pos = torch.einsum("kij,kbsj->kbsi", R_t, pos - camera_pos)
uv_pos
= ref_pos[..., :-1] / ref_pos[..., -1:] / scale
Can you briefly explain how this code implements projection? It's so hard to understand
Hi, thanks for your excellent and brief implementation!
def feature_matching(self, pos):
n_rays, n_samples, _ = pos.shape
pos = pos.unsqueeze(dim=0).expand([self.n, n_rays, n_samples, 3])
camera_pos = self.camera_pos[:, None, None, :]
camera_pos = camera_pos.expand_as(pos)
ref_pos = torch.einsum("kij,kbsj->kbsi", self.R_t, pos-camera_pos)
uv_pos = ref_pos[..., :-1] / ref_pos[..., -1:] / self.scale
uv_pos[..., 1] *= -1.0
return F.grid_sample(self.reference, uv_pos, align_corners=True, padding_mode="border")
In main/PixelNeRF/Dataset.py line 89
uv_pos = ref_pos[..., :-1] / ref_pos[..., -1:] / self.scale
This operation aims to transform 3D points from camera coordinate system to pixel coordinate system and scale to range [-1,1] .
But here the camera coordinate system is the OpenGL form (i.e. x->right, y->upper, z->inner) and most of the 3D points will have negative z-axis coordinate values. So I think we should use the absolute value of ref_pos[..., -1:]
to do the transformation, or we will get a upside-down reprojection result as I observed in experiment.
感谢您的复现。
def sample_rays_np(H, W, f, c2w):
# image coordinate (i,j)
# c2w:[:3,:3] --> [R,t]
i, j = np.meshgrid(np.arange(W, dtype=np.float32), np.arange(H, dtype=np.float32), indexing='xy')
dirs = np.stack([(i - W * .5 + 0.5) / f, -(j - H * .5 + 0.5) / f, -np.ones_like(i)], -1)
# print(dirs[..., None, :].shape)
# print(c2w[:3,:3].shape)
rays_d = np.sum(dirs[..., None, :] * c2w[:3, :3], -1)
rays_o = np.broadcast_to(c2w[:3, -1], np.shape(rays_d))
return rays_o, rays_d
你好,我问一下, 这个c2w读取的是pose, pose不是w2c吗。
另外这个地方最后为什么要加0.5呢?
dirs = np.stack([(i - W * .5 + 0.5) / f, -(j - H * .5 + 0.5) / f, -np.ones_like(i)], -1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.