facebookresearch / habitat-sim

A flexible, high-performance 3D simulator for Embodied AI research.
https://aihabitat.org/
MIT License
2.49k stars 408 forks source link

Is there any problem with collecting the intrinsic and extrinsic parameters of the camera like this? #2064

Open oskar0812 opened 1 year ago

oskar0812 commented 1 year ago

Habitat-Sim version

vx.x.x

Habitat is under active development, and we advise users to restrict themselves to stable releases. Are you using the latest release version of Habitat-Sim? Your question may already be addressed in the latest version. We may also not be able to help with problems in earlier versions because they sometimes lack the more verbose logging needed for debugging.

Main branch contains 'bleeding edge' code and should be used at your own risk.

Docs and Tutorials

Did you read the docs? https://aihabitat.org/docs/habitat-sim/

Did you check out the tutorials? https://aihabitat.org/tutorial/2020/

Perhaps your question is answered there. If not, carry on!

❓ Questions and Help

hfov=90 Intrinsic = np.array([ [1/np.tan(math.pi/4), 0., 0., 0.], [0., 1/np.tan(math.pi/4), 0., 0.], [0., 0., 1, 0], [0., 0., 0, 1]]) Extrinsics=np.array([sim.get_agent(0).get_state().rotation.w,sim.get_agent(0).get_state().rotation.x,sim.get_agent(0).get_state().rotation.y,sim.get_agent(0).get_state().rotation.z]) Extrinsics=quaternion_to_rotation_matrix(Extrinsics) Extrinsics[0][3]=sim.get_agent(0).get_state().position[0] Extrinsics[1][3]=sim.get_agent(0).get_state().position[1] Extrinsics[2][3]=sim.get_agent(0).get_state().position[2] print(Extrinsics)

if the width = 512, height = 512 fx =512, fy = 512 cx = 512 / 2 = 256 and cy = 512 / 2 = 256

But the output Intrinsic parameters and extrinsic parameters couldn't match the picture when I warped the picture. And i used Replica Dataset.I want to use this data to do some novel viewpoint synthesis tasks. I think I need some help, such as how to render the Replica image while outputting its camera intrinsic and extrinsic parameters.I would be grateful if someone could provide some help.

aclegg3 commented 1 year ago

Hey @oskar0812,

First thing I notice is that you are querying the state of the agent rather than the camera here: sim.get_agent(0).get_state() will return the agent's state. The camera, however is offset from the agent by some configured transformation. Instead, try something like agent_rotation = sim.get_agent(0)._sensors["color_sensor"].node.absolute_transformation(). The key is to get the camera's scene_node instead of the agent's.