Open ayushbaid opened 2 years ago
Sure, do it :-) Should be simple. Although, a slightly better API would be to give a set of cameras in a map, and give tracks as a vector of pairs (key, measurement), where key indexes into the cameras. That way you can allow for “incomplete” tracks. Using a map is a bit slower than a vector but avoids elaborate setup.
Although, with templates and using .at you can support both maps and vectors:
Template CAMERAS, KEY
void triangulate(const CAMERAS& cameras, const vector<map<KEY,Point2>& tracks) {
for [i,point]:
auto camera_i = cameras.at(i);
}
Feature
In the python wrapper, we have functions
triangulateNonLinear
andtriangulatePoint3
. These functions operate on a single track (i.e. they take input a collection of 2D measurements all belonging to the same 3D point and output one single 3D point.The request is to have a batch triangulation API, which takes input a set of cameras (2+), collection of 2D tracks (with each track having measurement in all the cameras), and outputs a collection of 3D point, one point for each camera. This new API is equivalent to calling the existing APIs in a loop.
Motivation
We expect the batch API to perform speed-up when performing triangulation for a 2-camera setup. In GTSFM, we plan to add 2-view bundle adjustment for each image pair. The first step in this process is to perform triangulation for all the correspondences between the 2 images, which usually run into thousands.
The triangulation for all the points is achieved by a loop in Python, and it consumes much more time than the final bundle adjustment. By having a batch API, we might be able to save some compute time.
Pitch
I request for a batch triangulation function, which will also be available in the Python wrapper, which performs the triangulation for a set of 2D tracks.
Alternatives
N/A
Additional context
N/A