diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..cd20be32fa7bddc1ece8f9354845d795786a436c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +1_19_Idle/1_19_Idle_view2.mp4 filter=lfs diff=lfs merge=lfs -text diff --git a/.ipynb_checkpoints/process-checkpoint.py b/.ipynb_checkpoints/process-checkpoint.py new file mode 100644 index 0000000000000000000000000000000000000000..2db5b11066686c0d26765962acd697942daf8862 --- /dev/null +++ b/.ipynb_checkpoints/process-checkpoint.py @@ -0,0 +1,126 @@ +import numpy as np +import torch +import os +import re +from packaging import version as pver + +def custom_meshgrid(*args): + # ref: https://pytorch.org/docs/stable/generated/torch.meshgrid.html?highlight=meshgrid#torch.meshgrid + if pver.parse(torch.__version__) < pver.parse('1.10'): + return torch.meshgrid(*args) + else: + return torch.meshgrid(*args, indexing='ij') + + +def ray_condition(K, c2w, H, W, device, flip_flag=None): + # c2w: B, V, 4, 4 + # K: B, V, 4 + + B, V = K.shape[:2] + + j, i = custom_meshgrid( + torch.linspace(0, H - 1, H, device=device, dtype=c2w.dtype), + torch.linspace(0, W - 1, W, device=device, dtype=c2w.dtype), + ) + i = i.reshape([1, 1, H * W]).expand([B, V, H * W]) + 0.5 # [B, V, HxW] + j = j.reshape([1, 1, H * W]).expand([B, V, H * W]) + 0.5 # [B, V, HxW] + + n_flip = torch.sum(flip_flag).item() if flip_flag is not None else 0 + if n_flip > 0: + j_flip, i_flip = custom_meshgrid( + torch.linspace(0, H - 1, H, device=device, dtype=c2w.dtype), + torch.linspace(W - 1, 0, W, device=device, dtype=c2w.dtype) + ) + i_flip = i_flip.reshape([1, 1, H * W]).expand(B, 1, H * W) + 0.5 + j_flip = j_flip.reshape([1, 1, H * W]).expand(B, 1, H * W) + 0.5 + i[:, flip_flag, ...] = i_flip + j[:, flip_flag, ...] = j_flip + + fx, fy, cx, cy = K.chunk(4, dim=-1) # B,V, 1 + + zs = torch.ones_like(i) # [B, V, HxW] + xs = (i - cx) / fx * zs + ys = (j - cy) / fy * zs + zs = zs.expand_as(ys) + + directions = torch.stack((xs, ys, zs), dim=-1) # B, V, HW, 3 + directions = directions / directions.norm(dim=-1, keepdim=True) # B, V, HW, 3 + + rays_d = directions @ c2w[..., :3, :3].transpose(-1, -2) # B, V, HW, 3 + rays_o = c2w[..., :3, 3] # B, V, 3 + rays_o = rays_o[:, :, None].expand_as(rays_d) # B, V, HW, 3 + # c2w @ dirctions + rays_dxo = torch.cross(rays_o, rays_d) # B, V, HW, 3 + plucker = torch.cat([rays_dxo, rays_d], dim=-1) + plucker = plucker.reshape(B, c2w.shape[1], H, W, 6) # B, V, H, W, 6 + # plucker = plucker.permute(0, 1, 4, 2, 3) + return plucker + +def plucker_from_camera_params( + K, R, t, W0, H0, cw_np, + H, W, + device='cpu', + normalize_intrinsics=True +): + """ + K, R, t, W0, H0 同 get_camera_params 返回, + cw_np 是 camera.matrix_world 转成的 numpy.ndarray (4×4)。 + H, W 是你要的光线网格尺寸。 + """ + # 1) 归一化 intrinsics + if normalize_intrinsics: + fx = K[0,0] / W0 + fy = K[1,1] / H0 + cx = K[0,2] / W0 + cy = K[1,2] / H0 + else: + fx, fy = K[0,0], K[1,1] + cx, cy = K[0,2], K[1,2] + + intrinsics = torch.tensor( + [[[fx, fy, cx, cy]]], + dtype=torch.float32, + device=device + ) # [1,1,4] + + # 2) cw_np 就是 c2w + # 直接转成张量,不要再调用 Matrix 方法 + c2w = torch.tensor(cw_np, dtype=torch.float32, device=device) + c2w = c2w.unsqueeze(0).unsqueeze(0) # [1,1,4,4] + + # 3) 调用 ray_condition + flip_flag = torch.zeros(1, dtype=torch.bool, device=device) + plucker = ray_condition( + intrinsics, + c2w, + H, W, + device=device, + flip_flag=flip_flag + ) # [1,1,H,W,6] + + return plucker[0,0] # [6, H, W] + + +dir_path = "1_19_Idle" +dict_files = sorted([os.path.join(dir_path, file) for file in os.listdir(dir_path) if file.endswith(".npy") and "dict" in file]) + + +for dict_file in dict_files: + params = np.load(dict_file, allow_pickle=True).item() + match_view = re.search(r'view(\d+)', str(dict_file)) + if match_view: + view = int(match_view.group(1)) + else: + view = None + + plucker_embedding = plucker_from_camera_params( + params['K'], params['R'], params['t'], params['W0'], params['H0'], params['cw'], + 480, 720, + device='cpu', + normalize_intrinsics=True + ) + plucker_embedding = torch.tensor(plucker_embedding).permute(2,0,1) + o = params['cw'][:3, 3] + r = np.linalg.norm(o) + plucker_embedding[:3] = plucker_embedding[:3] / r + torch.save(plucker_embedding, f"{view}.pt") \ No newline at end of file diff --git a/0.pt b/0.pt new file mode 100644 index 0000000000000000000000000000000000000000..d8c655b1d57bd43819e5a335aa01d24c1fa0b274 --- /dev/null +++ b/0.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d29c274d32b0692f5bbac360d85141b110ffe2554f899a4691f09a4b72be45a +size 8295422 diff --git a/1.pt b/1.pt new file mode 100644 index 0000000000000000000000000000000000000000..ff888beb87af8ee85a2cc709aa76a113e3aba624 --- /dev/null +++ b/1.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2672b6fae035043dda0a58dddc759f2c27fb7f45d45ecff0d712f99c515e85c +size 8295422 diff --git a/10.pt b/10.pt new file mode 100644 index 0000000000000000000000000000000000000000..c1fbed90e760a3ea55b2cd343e69fb4f4aca9765 --- /dev/null +++ b/10.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69a5825f8543b873cdcab777810c1f5bd965afc89ea6d204edb8771422917aae +size 8295491 diff --git a/11.pt b/11.pt new file mode 100644 index 0000000000000000000000000000000000000000..d83266c093b14717dcc87e122069b8abf3785575 --- /dev/null +++ b/11.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:482684c1201746cfa36fccdc44108441498f03652f31aa1221d99c3f3148ce8b +size 8295491 diff --git a/12.pt b/12.pt new file mode 100644 index 0000000000000000000000000000000000000000..f8b2668509d826084626984b2e98d8a04e648230 --- /dev/null +++ b/12.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdf7e1158b5eeec7b0408adaa6ef252f99cca5b125ed859d0caec079372e3801 +size 8295491 diff --git a/13.pt b/13.pt new file mode 100644 index 0000000000000000000000000000000000000000..5b453063fd8d28f28a8c0f1976814da3534fecb5 --- /dev/null +++ b/13.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:115e92c8eac909fd6a435042857ecada2a753b5da14202e20a972ba699da4579 +size 8295491 diff --git a/14.pt b/14.pt new file mode 100644 index 0000000000000000000000000000000000000000..aa2e231b9df9f0c17aef25e3562991804ead13be --- /dev/null +++ b/14.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9cad6a3a2ee3083f18133a9abbadbec86e71c0def94e10533b2f17004dfcb26 +size 8295491 diff --git a/15.pt b/15.pt new file mode 100644 index 0000000000000000000000000000000000000000..906032d884be46efe2da86fb2e97254fc9cd913e --- /dev/null +++ b/15.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aaddf6a42d682242b33b43ea59adee5c9d5073cbc7734b78bef16122b5aaba60 +size 8295491 diff --git a/16.pt b/16.pt new file mode 100644 index 0000000000000000000000000000000000000000..a1311de446d19a8fdfd9c57d0cb180738b74b6fb --- /dev/null +++ b/16.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb10275e0ae0be34abb48d945de700e6d74ece66389b2b2150ccc0a4755f8572 +size 8295491 diff --git a/17.pt b/17.pt new file mode 100644 index 0000000000000000000000000000000000000000..e9b8f8b44d391424b3b442e4a0b32ce664c7bcfb --- /dev/null +++ b/17.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa253f6009c5ea6914c667d0535fd9ea0b58384fc35a046a0d04949466c23e6d +size 8295491 diff --git a/18.pt b/18.pt new file mode 100644 index 0000000000000000000000000000000000000000..7a078b246496c8798e841ea379b8178aa8a94464 --- /dev/null +++ b/18.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22922711f62d00119c946d0bd0431cdd5418e1e3c8120609594e3390359335bd +size 8295491 diff --git a/19.pt b/19.pt new file mode 100644 index 0000000000000000000000000000000000000000..b6a400ddd6e1582a3e85cfed62dbbe41a62f2348 --- /dev/null +++ b/19.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ecae280ffa16cd50e73fe21eec617b7435b89f3e854ab6371882b11d93ef51b +size 8295491 diff --git a/1_19_Idle.zip b/1_19_Idle.zip new file mode 100644 index 0000000000000000000000000000000000000000..cb22d80d40be7a06d9a2cd184121de3adf1e712f --- /dev/null +++ b/1_19_Idle.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6eab299feba14b249e90309f788c555b9696c93a225e9c52d6e51d1beeb8446d +size 190798 diff --git a/1_19_Idle/1_19_Idle_view2.mp4 b/1_19_Idle/1_19_Idle_view2.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4a5dbfbd9b976f9b04b1233396b357771c796783 --- /dev/null +++ b/1_19_Idle/1_19_Idle_view2.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:baa5dd82d06b1f975ad6e2798b1707d6ef6d79b48fd23ad59a12d93f6b53b76b +size 164616 diff --git a/1_19_Idle/camera_dict_view0.npy b/1_19_Idle/camera_dict_view0.npy new file mode 100644 index 0000000000000000000000000000000000000000..2e7a85c04aabd354b29e27c377e7b7aa09909b2f --- /dev/null +++ b/1_19_Idle/camera_dict_view0.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e3b27145c63664af67e4cf9b2155fac7ddd91a4b1aa460fd9bcf96711a1d190 +size 834 diff --git a/1_19_Idle/camera_dict_view1.npy b/1_19_Idle/camera_dict_view1.npy new file mode 100644 index 0000000000000000000000000000000000000000..79b0ae30b3965bc04312e1ffa614a5067e3df802 --- /dev/null +++ b/1_19_Idle/camera_dict_view1.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:006f5cd771c2e87513e5d19e30928d7d833a241ca9939593a68036640b3807bd +size 834 diff --git a/1_19_Idle/camera_dict_view10.npy b/1_19_Idle/camera_dict_view10.npy new file mode 100644 index 0000000000000000000000000000000000000000..4473c9fce6b777fbe76d87fd564bb347c94d7326 --- /dev/null +++ b/1_19_Idle/camera_dict_view10.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c31ac9f6c4869f769a5293a188ae5ad474d4bbef4ceeb066edc5a9894c15e6b +size 834 diff --git a/1_19_Idle/camera_dict_view11.npy b/1_19_Idle/camera_dict_view11.npy new file mode 100644 index 0000000000000000000000000000000000000000..2c108bfb2a3b024c89146267f0daf59a477facaf --- /dev/null +++ b/1_19_Idle/camera_dict_view11.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea9ce0facfe271c09ac42d3ba9f53c883d724f11e35a3fcdd189d585df3dc0b7 +size 834 diff --git a/1_19_Idle/camera_dict_view12.npy b/1_19_Idle/camera_dict_view12.npy new file mode 100644 index 0000000000000000000000000000000000000000..c4aeee441007851ba092f13c701010e794d24d3f --- /dev/null +++ b/1_19_Idle/camera_dict_view12.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd03624b1f9053c757e3effbb12d18304875bc34f7e35f2128f7b2e7e8356722 +size 834 diff --git a/1_19_Idle/camera_dict_view13.npy b/1_19_Idle/camera_dict_view13.npy new file mode 100644 index 0000000000000000000000000000000000000000..ca82e9e6d63e1044b65875642595e4231e353877 --- /dev/null +++ b/1_19_Idle/camera_dict_view13.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eabf40198077e76b34e1da3c43d48a0a5c34ab6404b41d344e0aaeeb4b9d2fa8 +size 834 diff --git a/1_19_Idle/camera_dict_view14.npy b/1_19_Idle/camera_dict_view14.npy new file mode 100644 index 0000000000000000000000000000000000000000..d722a64ac483202312ee43077b4f939c54475129 --- /dev/null +++ b/1_19_Idle/camera_dict_view14.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e793e3d4867a92c4416914b124f928a1cd61c19a448e4665507d904aab8749f +size 834 diff --git a/1_19_Idle/camera_dict_view15.npy b/1_19_Idle/camera_dict_view15.npy new file mode 100644 index 0000000000000000000000000000000000000000..2b72dba496770a78b3dae0a39efd546cc6ba1fe0 --- /dev/null +++ b/1_19_Idle/camera_dict_view15.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc82b8796c4cb29d956b32dbac96398818ac8e6c3b3a219c00504fda917ef718 +size 834 diff --git a/1_19_Idle/camera_dict_view16.npy b/1_19_Idle/camera_dict_view16.npy new file mode 100644 index 0000000000000000000000000000000000000000..ed5e076d426fbc82d6798d32aea5e32006c875fc --- /dev/null +++ b/1_19_Idle/camera_dict_view16.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06c17de74771d4754e83336184483d389ce7dc12d7f57c935e886401b1510d43 +size 834 diff --git a/1_19_Idle/camera_dict_view17.npy b/1_19_Idle/camera_dict_view17.npy new file mode 100644 index 0000000000000000000000000000000000000000..85d8997c314d2af036ef1a9799e674ddf84d000e --- /dev/null +++ b/1_19_Idle/camera_dict_view17.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2aef4bc53c5ea56258f8701d5c9241e41cd087e421aaf408c0c417fd98507e0 +size 834 diff --git a/1_19_Idle/camera_dict_view18.npy b/1_19_Idle/camera_dict_view18.npy new file mode 100644 index 0000000000000000000000000000000000000000..18322accbd098e02ee3bf4cd96b9af8d84b14528 --- /dev/null +++ b/1_19_Idle/camera_dict_view18.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66dd051f360984afa8fae510ff0e667268cb08dbe2ef6a119dc90332328a8ee0 +size 834 diff --git a/1_19_Idle/camera_dict_view19.npy b/1_19_Idle/camera_dict_view19.npy new file mode 100644 index 0000000000000000000000000000000000000000..d13e947d76926caf761566add7047da454c375a3 --- /dev/null +++ b/1_19_Idle/camera_dict_view19.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7ba5e53b779416a509f41905c9d22776ded5f9f91326e5064618d3465232da5 +size 834 diff --git a/1_19_Idle/camera_dict_view2.npy b/1_19_Idle/camera_dict_view2.npy new file mode 100644 index 0000000000000000000000000000000000000000..57de5407c9fbf5de576125e586bfcade2a834d42 --- /dev/null +++ b/1_19_Idle/camera_dict_view2.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9555fa4fc0ca3705532631e861c25ae8c7e1b7a0937532a19a9906736a8c6cf +size 834 diff --git a/1_19_Idle/camera_dict_view20.npy b/1_19_Idle/camera_dict_view20.npy new file mode 100644 index 0000000000000000000000000000000000000000..2bd1d7c3f7e0d125fb75fa68bb908269994cdd5a --- /dev/null +++ b/1_19_Idle/camera_dict_view20.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97683a53afc98c877b8e7b6d8323b54cb450f4077f35114ca9b4549b5a5adbde +size 834 diff --git a/1_19_Idle/camera_dict_view3.npy b/1_19_Idle/camera_dict_view3.npy new file mode 100644 index 0000000000000000000000000000000000000000..15e75052b10aee840fa628497799da7b1c1c4ffa --- /dev/null +++ b/1_19_Idle/camera_dict_view3.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91b51b1d352043bee61e272ceb753ed0e7b4920fa3ef5c807ec71f7c1a2679c6 +size 834 diff --git a/1_19_Idle/camera_dict_view4.npy b/1_19_Idle/camera_dict_view4.npy new file mode 100644 index 0000000000000000000000000000000000000000..87008632dae7ee717757f6dd6a928287591d3092 --- /dev/null +++ b/1_19_Idle/camera_dict_view4.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:155b797498f8411a7a85356e3f0d4244bac23c5bcf76b30f84ceb64cf00c553d +size 834 diff --git a/1_19_Idle/camera_dict_view5.npy b/1_19_Idle/camera_dict_view5.npy new file mode 100644 index 0000000000000000000000000000000000000000..7fc1ca5cdefbdad49b60bbf121bdc62437435036 --- /dev/null +++ b/1_19_Idle/camera_dict_view5.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3eae1a35b2674ee7d32f64b9173574885805038619a6ecc76075d218445b3117 +size 834 diff --git a/1_19_Idle/camera_dict_view6.npy b/1_19_Idle/camera_dict_view6.npy new file mode 100644 index 0000000000000000000000000000000000000000..f3149179ff825a3eddedd7664d838578926eacb7 --- /dev/null +++ b/1_19_Idle/camera_dict_view6.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9a180f5a4f9835e75e368faeeaa34681407377ffdb03e968bd5b7417b9267cb +size 834 diff --git a/1_19_Idle/camera_dict_view7.npy b/1_19_Idle/camera_dict_view7.npy new file mode 100644 index 0000000000000000000000000000000000000000..5b1ee25aeb978767a310fddf331dbd1c205f510f --- /dev/null +++ b/1_19_Idle/camera_dict_view7.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1167719e14355c0a4079bc310e2cd770e7569110b3be5ff7b790e68996b8b86a +size 834 diff --git a/1_19_Idle/camera_dict_view8.npy b/1_19_Idle/camera_dict_view8.npy new file mode 100644 index 0000000000000000000000000000000000000000..e9ee2528bebb9d9b83e4fcda48e301b70fda94bb --- /dev/null +++ b/1_19_Idle/camera_dict_view8.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2248ffb358e1267a5c63aaec12ff1b6a7e0d14a0b014bfed16f434cfbcc316f6 +size 834 diff --git a/1_19_Idle/camera_dict_view9.npy b/1_19_Idle/camera_dict_view9.npy new file mode 100644 index 0000000000000000000000000000000000000000..2e62bcc3e6849e68a65f6db4337c4ad4c7876834 --- /dev/null +++ b/1_19_Idle/camera_dict_view9.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf6e83371c3767808aa94b62416a80ed575a280c74ac99bc64fd371a6d4e898e +size 834 diff --git a/1_19_Idle/camera_position_view0.npy b/1_19_Idle/camera_position_view0.npy new file mode 100644 index 0000000000000000000000000000000000000000..d38d0fb161b0e15284d24ef12c0a3a3a46229c62 --- /dev/null +++ b/1_19_Idle/camera_position_view0.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24fdbd40689e7a98decb4517516254431672c2ebe81738a3eda194553f65dca3 +size 505 diff --git a/1_19_Idle/camera_position_view1.npy b/1_19_Idle/camera_position_view1.npy new file mode 100644 index 0000000000000000000000000000000000000000..a3da7769b1d87e5d16d383e6618e8feb29f58380 --- /dev/null +++ b/1_19_Idle/camera_position_view1.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:959d618c7bf506e87b763a56cf723b24370ddde1abbdf7fe9eb2818534be7252 +size 505 diff --git a/1_19_Idle/camera_position_view10.npy b/1_19_Idle/camera_position_view10.npy new file mode 100644 index 0000000000000000000000000000000000000000..75dde13451d707b95e31bcc5c4701eae4f11cce6 --- /dev/null +++ b/1_19_Idle/camera_position_view10.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70d257646cfbbfb22b4198f543a9992fffe3da7ca4bb9aea11764b87f3d9cdfb +size 505 diff --git a/1_19_Idle/camera_position_view11.npy b/1_19_Idle/camera_position_view11.npy new file mode 100644 index 0000000000000000000000000000000000000000..4a097af9a37a1488a17b9e0cbb5063fde560429c --- /dev/null +++ b/1_19_Idle/camera_position_view11.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cce4d36012bada079609bdcffa3690fd7024ccb83c9347f897e09459d33633d3 +size 505 diff --git a/1_19_Idle/camera_position_view12.npy b/1_19_Idle/camera_position_view12.npy new file mode 100644 index 0000000000000000000000000000000000000000..84de6f6b227184af671a96620147025fbab303ad --- /dev/null +++ b/1_19_Idle/camera_position_view12.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75495a9c3e945157a0ea683d078a18c99e087f3711825a009825fa7b82df24fc +size 505 diff --git a/1_19_Idle/camera_position_view13.npy b/1_19_Idle/camera_position_view13.npy new file mode 100644 index 0000000000000000000000000000000000000000..6d300f756599dfae2674328cf3a4e942bd470725 --- /dev/null +++ b/1_19_Idle/camera_position_view13.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2bda4d860a6412340326f03aedee7dcd74fd6c8de17792a3b8775700b89075e +size 505 diff --git a/1_19_Idle/camera_position_view14.npy b/1_19_Idle/camera_position_view14.npy new file mode 100644 index 0000000000000000000000000000000000000000..98137fdd1ef0dfd588ebe3dcb9535929e2014743 --- /dev/null +++ b/1_19_Idle/camera_position_view14.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:018d26a2ff30efa9c091ee127eae8a4f0dfd460963498c8ee4d123be97f1328b +size 505 diff --git a/1_19_Idle/camera_position_view15.npy b/1_19_Idle/camera_position_view15.npy new file mode 100644 index 0000000000000000000000000000000000000000..1399ac5aea1a865348d0f9d705aed57d96203f5c --- /dev/null +++ b/1_19_Idle/camera_position_view15.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2f3c223458f474b3fd43894bba1afc1c1466c94c0a6e9f89de6be1cb59779b7 +size 505 diff --git a/1_19_Idle/camera_position_view16.npy b/1_19_Idle/camera_position_view16.npy new file mode 100644 index 0000000000000000000000000000000000000000..d7c7ba22d09bf0c2430bfd126e1b82109af9148b --- /dev/null +++ b/1_19_Idle/camera_position_view16.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b3faa41547e7fb41f3f25c190ac1396475510fb4b24245d9340edecb9a10fc1 +size 505 diff --git a/1_19_Idle/camera_position_view17.npy b/1_19_Idle/camera_position_view17.npy new file mode 100644 index 0000000000000000000000000000000000000000..d2bff4d970231663282e26d1b9d8acf93a716c6b --- /dev/null +++ b/1_19_Idle/camera_position_view17.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7cbec4a5087172c157d5bf366f7af2a102c666898baa2749b4d8d90bdf6c8f31 +size 505 diff --git a/1_19_Idle/camera_position_view18.npy b/1_19_Idle/camera_position_view18.npy new file mode 100644 index 0000000000000000000000000000000000000000..6d0255e7f9294638ae31b65c13b44acf99c39ebb --- /dev/null +++ b/1_19_Idle/camera_position_view18.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46961e190125f751f86cbd32cc045b50cfec5f1277c71813c9728a931ac367c3 +size 505 diff --git a/1_19_Idle/camera_position_view19.npy b/1_19_Idle/camera_position_view19.npy new file mode 100644 index 0000000000000000000000000000000000000000..dfccdd8592e0330976d15e87f6eadd695715c8aa --- /dev/null +++ b/1_19_Idle/camera_position_view19.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1c236914aa98a3bad7fd29e4b65991dd590cfc1e97e6fbe832c6d32c70925b4 +size 505 diff --git a/1_19_Idle/camera_position_view2.npy b/1_19_Idle/camera_position_view2.npy new file mode 100644 index 0000000000000000000000000000000000000000..73629d69e31cc6013dba0899aa1cce11e3a06ac2 --- /dev/null +++ b/1_19_Idle/camera_position_view2.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67a7136283021cd773931441471d11816d86257d0b3248c530e9bd41e400a5f8 +size 505 diff --git a/1_19_Idle/camera_position_view20.npy b/1_19_Idle/camera_position_view20.npy new file mode 100644 index 0000000000000000000000000000000000000000..e27398da8f95b90af261742615b9019eb33c51fe --- /dev/null +++ b/1_19_Idle/camera_position_view20.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95603163953273d6728b9701a20cf08285aa23df5c6d6c60ef27fb2b6715e653 +size 505 diff --git a/1_19_Idle/camera_position_view3.npy b/1_19_Idle/camera_position_view3.npy new file mode 100644 index 0000000000000000000000000000000000000000..5ebdb0a6c23ab75d87ce9e446f40b9cd1f42bdcb --- /dev/null +++ b/1_19_Idle/camera_position_view3.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33f8afcbc4629e1c0a101fbab15171061bcfb022fb4ee839c83a2acd20faba56 +size 505 diff --git a/1_19_Idle/camera_position_view4.npy b/1_19_Idle/camera_position_view4.npy new file mode 100644 index 0000000000000000000000000000000000000000..f3b6f9ad4a967c92db680d851cda4f2fccb03025 --- /dev/null +++ b/1_19_Idle/camera_position_view4.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70a85062c46c825ff27e60e895e03f3db60958c2c38410f589880a6357013c54 +size 505 diff --git a/1_19_Idle/camera_position_view5.npy b/1_19_Idle/camera_position_view5.npy new file mode 100644 index 0000000000000000000000000000000000000000..959721199cbb2a44081216a47fc7dd06311de527 --- /dev/null +++ b/1_19_Idle/camera_position_view5.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdf57e81949737baadf67e1ef44aa4aa28de72da8c44430ba08284a9f0d7b73f +size 505 diff --git a/1_19_Idle/camera_position_view6.npy b/1_19_Idle/camera_position_view6.npy new file mode 100644 index 0000000000000000000000000000000000000000..f4395b774cab0821ecfdfe3f6822cbf25e0d27e1 --- /dev/null +++ b/1_19_Idle/camera_position_view6.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6842680cc9855f19dcc750dfc93ecf66f8a46da76c6bf19c0cc7a47cabf9319 +size 505 diff --git a/1_19_Idle/camera_position_view7.npy b/1_19_Idle/camera_position_view7.npy new file mode 100644 index 0000000000000000000000000000000000000000..f9d3f9ff44174d651dd07037b0a54e2ebe52e0f2 --- /dev/null +++ b/1_19_Idle/camera_position_view7.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:369b47e258846f73725199c09a2537c48b53c69ddb668f20de8f92a40dfb15a8 +size 505 diff --git a/1_19_Idle/camera_position_view8.npy b/1_19_Idle/camera_position_view8.npy new file mode 100644 index 0000000000000000000000000000000000000000..e471f29f6664ad2957fdeca354ae216df609ffaf --- /dev/null +++ b/1_19_Idle/camera_position_view8.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f71ad008f34d46201cf962b1d5fab3ac93955d84bd3aed5f2b82b482ae1e965 +size 505 diff --git a/1_19_Idle/camera_position_view9.npy b/1_19_Idle/camera_position_view9.npy new file mode 100644 index 0000000000000000000000000000000000000000..30e98a2d225b7bb5da8fa34faa1c4256a5eb8679 --- /dev/null +++ b/1_19_Idle/camera_position_view9.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a35dccf04bc77d4d35d46069178409d4441a9bd623cfaf7ba84588dc66dd92e +size 505 diff --git a/2.pt b/2.pt new file mode 100644 index 0000000000000000000000000000000000000000..a98e8e1062c679fac816b0d796e373b1661b64a5 --- /dev/null +++ b/2.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1dbc1c8fad3c25f6681f7373ad88b91cb02502487da4b87bd894361e69e0efb +size 8295422 diff --git a/20.pt b/20.pt new file mode 100644 index 0000000000000000000000000000000000000000..efc9d37971dd45f92666a12c2a1a0988b8768d02 --- /dev/null +++ b/20.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2de5fed811434faf3afeaee86e8f852d812be49e7048dd76995924517d284d36 +size 8295491 diff --git a/3.pt b/3.pt new file mode 100644 index 0000000000000000000000000000000000000000..ef4e0a42ad1548672d9861c4d3cac7f307bca2f5 --- /dev/null +++ b/3.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74a3aadda727351fe36321a1267ab8733979613add618e257aef15b4d65ad49c +size 8295422 diff --git a/4.pt b/4.pt new file mode 100644 index 0000000000000000000000000000000000000000..9360d15725e09a1ae381d804eb5f83afd1ba5802 --- /dev/null +++ b/4.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a465788437b99b39c0b70f4b452af7fd55454520bd6251e9558a00af2612ad1 +size 8295422 diff --git a/5.pt b/5.pt new file mode 100644 index 0000000000000000000000000000000000000000..62a1d443087e724915547b2cb4da302309ded8bc --- /dev/null +++ b/5.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a23654d384f92dd38e4e8de8c273f905630909e3543409709e35bff234cf074 +size 8295422 diff --git a/6.pt b/6.pt new file mode 100644 index 0000000000000000000000000000000000000000..5175ed1677557e5c1f02162226a083dcf6a6cb8e --- /dev/null +++ b/6.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f477d4185aa3466f950714c68f2b56862184dde1dc0c26dcd2197110fdfd59f9 +size 8295422 diff --git a/7.pt b/7.pt new file mode 100644 index 0000000000000000000000000000000000000000..09ccf39e1df6823f30578591c723d9bb50fae593 --- /dev/null +++ b/7.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b771768114de78b71d0f732ace435e36fa41a5e98cb0cec442d893d1cd51c3d6 +size 8295422 diff --git a/8.pt b/8.pt new file mode 100644 index 0000000000000000000000000000000000000000..51f3c7c6ba4a08ca822d5e44e56d517b8e0a3ffb --- /dev/null +++ b/8.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1aa1fe6126cbbe0f4f8357ef0d8b264bbe2484c5141ce080cc1faaf0035e1010 +size 8295422 diff --git a/9.pt b/9.pt new file mode 100644 index 0000000000000000000000000000000000000000..697bd791820462926c0e0c28f7e052c8c930a3da --- /dev/null +++ b/9.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dfaca72ef5b5ecb804b5f3f0892df29b224c1791c29320974d17f2b3d48438d +size 8295422 diff --git a/process.py b/process.py new file mode 100644 index 0000000000000000000000000000000000000000..2db5b11066686c0d26765962acd697942daf8862 --- /dev/null +++ b/process.py @@ -0,0 +1,126 @@ +import numpy as np +import torch +import os +import re +from packaging import version as pver + +def custom_meshgrid(*args): + # ref: https://pytorch.org/docs/stable/generated/torch.meshgrid.html?highlight=meshgrid#torch.meshgrid + if pver.parse(torch.__version__) < pver.parse('1.10'): + return torch.meshgrid(*args) + else: + return torch.meshgrid(*args, indexing='ij') + + +def ray_condition(K, c2w, H, W, device, flip_flag=None): + # c2w: B, V, 4, 4 + # K: B, V, 4 + + B, V = K.shape[:2] + + j, i = custom_meshgrid( + torch.linspace(0, H - 1, H, device=device, dtype=c2w.dtype), + torch.linspace(0, W - 1, W, device=device, dtype=c2w.dtype), + ) + i = i.reshape([1, 1, H * W]).expand([B, V, H * W]) + 0.5 # [B, V, HxW] + j = j.reshape([1, 1, H * W]).expand([B, V, H * W]) + 0.5 # [B, V, HxW] + + n_flip = torch.sum(flip_flag).item() if flip_flag is not None else 0 + if n_flip > 0: + j_flip, i_flip = custom_meshgrid( + torch.linspace(0, H - 1, H, device=device, dtype=c2w.dtype), + torch.linspace(W - 1, 0, W, device=device, dtype=c2w.dtype) + ) + i_flip = i_flip.reshape([1, 1, H * W]).expand(B, 1, H * W) + 0.5 + j_flip = j_flip.reshape([1, 1, H * W]).expand(B, 1, H * W) + 0.5 + i[:, flip_flag, ...] = i_flip + j[:, flip_flag, ...] = j_flip + + fx, fy, cx, cy = K.chunk(4, dim=-1) # B,V, 1 + + zs = torch.ones_like(i) # [B, V, HxW] + xs = (i - cx) / fx * zs + ys = (j - cy) / fy * zs + zs = zs.expand_as(ys) + + directions = torch.stack((xs, ys, zs), dim=-1) # B, V, HW, 3 + directions = directions / directions.norm(dim=-1, keepdim=True) # B, V, HW, 3 + + rays_d = directions @ c2w[..., :3, :3].transpose(-1, -2) # B, V, HW, 3 + rays_o = c2w[..., :3, 3] # B, V, 3 + rays_o = rays_o[:, :, None].expand_as(rays_d) # B, V, HW, 3 + # c2w @ dirctions + rays_dxo = torch.cross(rays_o, rays_d) # B, V, HW, 3 + plucker = torch.cat([rays_dxo, rays_d], dim=-1) + plucker = plucker.reshape(B, c2w.shape[1], H, W, 6) # B, V, H, W, 6 + # plucker = plucker.permute(0, 1, 4, 2, 3) + return plucker + +def plucker_from_camera_params( + K, R, t, W0, H0, cw_np, + H, W, + device='cpu', + normalize_intrinsics=True +): + """ + K, R, t, W0, H0 同 get_camera_params 返回, + cw_np 是 camera.matrix_world 转成的 numpy.ndarray (4×4)。 + H, W 是你要的光线网格尺寸。 + """ + # 1) 归一化 intrinsics + if normalize_intrinsics: + fx = K[0,0] / W0 + fy = K[1,1] / H0 + cx = K[0,2] / W0 + cy = K[1,2] / H0 + else: + fx, fy = K[0,0], K[1,1] + cx, cy = K[0,2], K[1,2] + + intrinsics = torch.tensor( + [[[fx, fy, cx, cy]]], + dtype=torch.float32, + device=device + ) # [1,1,4] + + # 2) cw_np 就是 c2w + # 直接转成张量,不要再调用 Matrix 方法 + c2w = torch.tensor(cw_np, dtype=torch.float32, device=device) + c2w = c2w.unsqueeze(0).unsqueeze(0) # [1,1,4,4] + + # 3) 调用 ray_condition + flip_flag = torch.zeros(1, dtype=torch.bool, device=device) + plucker = ray_condition( + intrinsics, + c2w, + H, W, + device=device, + flip_flag=flip_flag + ) # [1,1,H,W,6] + + return plucker[0,0] # [6, H, W] + + +dir_path = "1_19_Idle" +dict_files = sorted([os.path.join(dir_path, file) for file in os.listdir(dir_path) if file.endswith(".npy") and "dict" in file]) + + +for dict_file in dict_files: + params = np.load(dict_file, allow_pickle=True).item() + match_view = re.search(r'view(\d+)', str(dict_file)) + if match_view: + view = int(match_view.group(1)) + else: + view = None + + plucker_embedding = plucker_from_camera_params( + params['K'], params['R'], params['t'], params['W0'], params['H0'], params['cw'], + 480, 720, + device='cpu', + normalize_intrinsics=True + ) + plucker_embedding = torch.tensor(plucker_embedding).permute(2,0,1) + o = params['cw'][:3, 3] + r = np.linalg.norm(o) + plucker_embedding[:3] = plucker_embedding[:3] / r + torch.save(plucker_embedding, f"{view}.pt") \ No newline at end of file