RainerKuemmerle / g2o

g2o: A General Framework for Graph Optimization
3.1k stars 1.11k forks source link

About refine camera intrinsic (fx,fy,cx,cy) #625

Closed lzyplayer closed 1 year ago

lzyplayer commented 1 year ago

Some pre-defined edges, such as EdgeProjectXYZ2UV, EdgeSE3ProjectXYZ, are used during BA. However, they can only set unchangeable camera parameters. I'm wondering if I can set optimizable camera parameters.

I found Vertex VertexIntrinsics in g2o/types/sba/vertex_intrinsics.h. And its oplusImpl() function is implemented which means it can be optimized.

/**
 * \brief Vertex encoding the intrinsics of the camera fx, fy, cx, xy, baseline;
 */
class G2O_TYPES_SBA_API VertexIntrinsics : public BaseVertex<4, Eigen::Matrix<number_t, 5, 1, Eigen::ColMajor> >

It seems to be the one I'm looking for. Yet I cannot find a type of Ternary-Edge that link this vertex, camera pose vertex, and 3D world point vertex. Or any other edge that takes this type of vertex.

It would be great if somebody could share an example or some explanation about how this vertex works. Or any other way to optimize camera intrinsic in g2o.

lzyplayer commented 1 year ago

515 talks about this feature

lzyplayer commented 1 year ago

@salahkhan94 Could you please share some insight about this?

lzyplayer commented 1 year ago

I managed to solve it by defining a Ternary edge that links the camera intrinsic Vertex (VertexIntrinsics), camera pose Vertex (VertexSE3 or VertexSE3Expmap), and Observation Target (Vertex SE3 in my case, or VertexPointXYZ ). There will be only one VertexIntrinsics in the graph.

If you are looking for a ternary edge example, check edge_project_psi2uv.h. Thanks again for such great work.

goktugyildirim commented 1 year ago

Can you provide the Jacobian of the VertexSE3?