uoip / g2opy

Python binding of SLAM graph optimization framework g2o
668 stars 176 forks source link

How to set camera intrinsics for edge? #31

Open medakk opened 5 years ago

medakk commented 5 years ago

For EdgeSE3ProjectXYZ, we can set the camera intrinsics with the public fx, fy, cx, cy values, in the g2o codebase.

How do I set these values in g2opy?

medakk commented 5 years ago

For now, I changed the definition of EdgeSE3ProjectXYZ in this file:

    // Projection using focal_length in x and y directions
    py::class_<EdgeSE3ProjectXYZ, BaseBinaryEdge<2, Vector2D, VertexSBAPointXYZ, VertexSE3Expmap>>(m, "EdgeSE3ProjectXYZ")
        .def(py::init<>())
        .def("compute_error", &EdgeSE3ProjectXYZ::computeError)
        .def("is_depth_positive", &EdgeSE3ProjectXYZ::isDepthPositive)
        .def("linearize_oplus", &EdgeSE3ProjectXYZ::linearizeOplus)
        .def("cam_project", &EdgeSE3ProjectXYZ::cam_project)
        .def_readwrite("fx", &EdgeSE3ProjectXYZ::fx)
        .def_readwrite("fy", &EdgeSE3ProjectXYZ::fy)
        .def_readwrite("cx", &EdgeSE3ProjectXYZ::cx)
        .def_readwrite("cy", &EdgeSE3ProjectXYZ::cy)
    ;
yiakwy-enterprise-roborock commented 4 years ago

@medakk does it work well ? @uoip Some projects such as ORB-SLam use the same way to add poses as vertices.

medakk commented 4 years ago

@yiakwy-enterprise-roborock Its been a while since I used g2opy, but IIRC it worked fine.

yiakwy-enterprise-roborock commented 4 years ago

I confirmed that modifying these attributes works well with EdgeSE3ProjectXYZ python bindings. @medakk I suggested mark this question as resolved.

medakk commented 4 years ago

I wouldn't consider it resolved yet: ideally this should be a part of the g2opy codebase, and I'm not sure how many other classes have such missing attributes.