Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camera pose I drew did not match the camera pose directly viewed from the MVS file #1148

Open
JV-X opened this issue Jun 5, 2024 · 2 comments

Comments

@JV-X
Copy link

JV-X commented Jun 5, 2024

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:
Idraw
idraw2

Camera pose as seen in the MVS file:
frommvs
frommvs1

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.

@cdcseacave
Copy link
Owner

the full description of how to interpret the camera matrices is in the Interface.h file

@JV-X
Copy link
Author

JV-X commented Jun 6, 2024

the full description of how to interpret the camera matrices is in the Interface.h file

thanks for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants