openMVS
openMVS copied to clipboard
camera pose I drew did not match the camera pose directly viewed from the MVS file
Hi, I generated a JSON file from the MVS file and read the camera pose from the JSON file.
I used Open3D to visualize the read camera pose and the point cloud read from the PLY file.
However, when I rendered the 3D view, I found that the camera pose I drew did not match the camera pose directly viewed from the MVS file. They are as follows:
Camera pose as I drew it:
Camera pose as seen in the MVS file:
Here is my drawing code:
import json
import numpy as np
import open3d as o3d
def camera3():
file_path = "test\scene_2.json"
data = None
with open(file_path,'r') as f:
data = json.loads(f.read())['platforms'][0]
K = np.array(data['cameras'][0]['K'])
camera = data['cameras'][0]
poses = camera['poses']
vizualizer = o3d.visualization.Visualizer()
vizualizer.create_window(width=camera['width'], height=camera['height'])
for pose in poses:
R = np.array(pose['R'])
C = np.array(pose['C'])
intrinsic = o3d.camera.PinholeCameraIntrinsic()
intrinsic.set_intrinsics(
width=data['cameras'][0]['width'],
height=data['cameras'][0]['height'],
fx=K[0, 0],
fy=K[1, 1],
cx=K[0, 2],
cy=K[1, 2]
)
extrinsic = np.eye(4)
extrinsic[:3, :3] = R
extrinsic[:3, 3] = C
camera_lineset = o3d.geometry.LineSet.create_camera_visualization(
intrinsic=intrinsic,
extrinsic=extrinsic,
scale=0.1
)
vizualizer.add_geometry(camera_lineset)
pcd = o3d.io.read_point_cloud("test/texture.ply")
# o3d.visualization.draw_geometries([camera_lineset, pcd])
vizualizer.add_geometry(pcd)
vizualizer.run()
if __name__ == '__main__':
camera3()
Here are the files that I used: test.zip
I don't know why there is such a discrepancy. Is there something wrong with my code? any suggestions? thanks for your reply.