qcr/gtsam-quadrics

Python QuadricCamera.project() not working

Closed this issue · 2 comments

There are two functions in QuadricCamera.cpp by name of QuadricCamera::project. I am trying to use the 2nd definition in my code but getting error as follows:

TypeError: project(): incompatible function arguments. The following argument types are supported:
    1. (quadric: gtsam_quadrics.ConstrainedDualQuadric, pose: gtsam.gtsam.Pose3, calibration: gtsam.gtsam.Cal3_S2) -> gtsam_quadrics.DualConic
    Invoked with: 362.452 133.812 382.353  188.83
, R: [
        -0.999557, -0.0141918, -0.0252936;
        0.0152258, 0.485496, -0.8741;
        0.024685, -0.874117, -0.485054
]
t: -0.6832  2.6909  1.7373
, Cal3_S2[
        535.4, 0, 320.1;
        0, 539.2, 247.6;
        0, 0, 1
]

Want to use this definition

std::vector<Vector4> QuadricCamera::project(const AlignedBox2& box, const Pose3& pose, const boost::shared_ptr<Cal3_S2>& calibration) {
  std::vector<Vector4> planes;
  for (auto line : box.lines()) {
    Vector4 plane = QuadricCamera::transformToImage(pose, calibration).transpose() * line;
    planes.push_back(plane);
  }
  return planes;
}

We can definitely look at exposing this method to the python side.
In the mean time you can do this in python directly with the following:

# get the projection matrix
P = gtsam_quadrics.QuadricCamera.transformToImage(pose, calibration).transpose()

# project each line to a plane 
planes = []
lines = box.lines()
for i in range(lines.size()):
    line = lines.at(i)
    plane = P @ line
    planes.append(plane)

yeah, I did that, it works. Thanks