andyyankai / psdr-room

PSDR-Room: Single Photo to Scene using Differentiable Rendering
24 stars 2 forks source link

perspective camera with intrinsic matrix #14

Open ZheningHuang opened 3 days ago

ZheningHuang commented 3 days ago

Dear PSDR-room team,

Thank you for providing this amazing work.

I'm curious if you have the option to set the psdr.PerspectiveCamera with camera intrinsic parameters [fx, fy, c_x, c_y].

Upon reviewing the source code of psdr-jit, it appears that this is possible:

SDR_CLASS_DECL_BEGIN(PerspectiveCamera, final, Sensor)
public:
    PerspectiveCamera(float fov_x, float near, float far) : m_fov_x(fov_x), m_near_clip(near), m_far_clip(far), m_use_intrinsic(false) {}
    PerspectiveCamera(float fx, float fy, float cx, float cy, float near, float far) 
        : m_fx(fx), m_fy(fy), m_cx(cx), m_cy(cy), m_near_clip(near), m_far_clip(far), m_use_intrinsic(true) {};

However, I am unsure if this functionality is usable in the Python API. I would appreciate your guidance on this matter.

Best Zhening

andyyankai commented 3 days ago

Yes, there is also python binding to load camera intrinsic. You can check the psdr.cpp in psdr-jit for the python binding code. I can send an instruction later today(out for holiday)

ZheningHuang commented 3 days ago

This is great! thanks a lot! looking forward to it!

andyyankai commented 3 days ago

Something like this: Let me know if this work.

psdr_sensor = psdr_jit.PerspectiveCamera(sensor['fx'], sensor['fy'], sensor['cx'], sensor['cy'], sensor['near'], sensor['far'])
psdr_sensor.to_world = Matrix4fD(sensor['to_world'].reshape(1, 4, 4))
psdr_scene.add_Sensor(psdr_sensor)