Closed hvkwak closed 1 year ago
I finally got this. The coordinate system of my dataset is RFU and we need this in DRB. (Typical output from COLMAP may be RDF. Note that it was from RDF to DRB in MegaNeRF.) Key idea is that we use permutation matrices but know when to change the basis vectors when transforming rotation matrices. For example, P*c2w*inv(P)
transforms c2w, but basis vectors(or convention) won't change, i.e. (0, 0, 1) is still (0, 0, 1). (For more details: https://www.youtube.com/watch?v=P2LTAUO1TdA&t=662s).
I refer to the script colmap_to_meganerf.py
provided by the author of this repo. If the dataset is in RFU,
# 1. change c2w from RFU to RDF, basis vectors also change to RDF
c2w[:3, :3] = np.matmul(RFU_to_RDF_NUMPY, c2w[:3, :3])
# 2. change RDF to DRB, but basis vector stays same here because it is multiplied on both sides: still RDF
c2w[:3, :3] = np.matmul(RDF_to_DRB_NUMPY, c2w[:3, :3])@np.linalg.inv(RDF_to_DRB_NUMPY)
# 3. Camera position t is easy. Just transfrom from RFU to DRB.
c2w[:3, 3] = np.matmul(RFU_to_DRB_NUMPY, c2w[:3, 3])
so that we have camera extrinsics conditions same as author's example of transforming from RDF to DRB where basis vectors are based on RDF.
@hvkwak From the following code line 34 - 51 https://github.com/Fyusion/LLFF/blob/c6e27b1ee59cb18f054ccb0f87a90214dbe70482/llff/poses/pose_utils.py#L51 I found the procedure to consturct c2w is the same betweem llff and mega-nerf, but the llff didn't make the Pc2winv(P) . I'm confused ! So why the transforming from RDF to DRB should keep the basis vector to be RDF and do the Pc2winv(P) ?
Thank you very much!
@chufall It's something weeks ago so I don't remember all the details completely, I tested several scenarios including llff, found that both preprocessings(llff and meganerf) are fine. The main difference in llff is that it just changes the rotation matrix(without using P@C2W@inv(P) ) in line 51. Ray operations that follow after this line (https://github.com/bmild/nerf/blob/18b8aebda6700ed659cb27a0c348b737a5f6ab60/load_llff.py#L246) were also correctly organized. (Tested with the toy camera frustum example I wroted above.) I remember that those preprocessings are to match the coordinate systems with the ray functions(meganerf keeps it in DRB with RDF basis, I guess.).
@hvkwak Thanks a lot , I'll try to test my data.
I'd like to know where I make mistakes when running
colmap_to_mega_nerf.py
in this repo to train a custom dataset which is geo-referenced bymodel_aligner
ofCOLMAP
. After analyzing several repos and issues in this repo, I noticed that my camera poses may be assumed to be (due tomodel_aligner
) starting with XYZs being (Forward, Left, Up) or (Right, Backward, Up). For me Z being Up is important, but XYs are whatever. (Permutation matricesFLU_2_DRB
andRBU_2_DRB
transforming these two to DRB(Down, Right, Backward) show positive and negative determinant, respectively.)Code below will first visualize original camera poses all watching (0, 0, 0) and the following visualization is where
FLU_2_DRB
is used to transform the rotation matrix and the translation vector in camera extrinsics. Unfortunately I was unable to reproduce the transformed camera poses all watching (0, 0, 0), somehow they are 90 degrees watching away. Changing the columns of the [R|t] matrix into (1, -0, 2, 3) order was not a solution. (This only rotates the camera image planes)Where am I making mistakes? Any ideas or help are very appreciated. Thanks.