opencv_contrib
opencv_contrib copied to clipboard
Wrong parameter description of cv::sfm::triangulatePoints()
System information (version)
- OpenCV => 4.6.0
- Operating System / Platform => Linux / Ubuntu 22.04 LTS
- Compiler => gcc 11.3.0
Detailed description
According to the documentation of cv::sfm::triangulatePoints() function (https://docs.opencv.org/4.6.0/d0/dbd/group__triangulation.html#ga211c855276b3084f3bbd8b2d9161dc74) the first input parameter and its description are as follows:
points2d | Input vector of vectors of 2d points (the inner vector is per image). Has to be 2 X N.
Following this description, the 2d points are formatted as std::vector<std::vector<cv::Point2f>>,
but then cv::sfm::triangulatePoints(points_2d, projection_matrices, points_3d) throws the error:
(-215:Assertion failed) points2d_tmp[i].rows == 2 && points2d_tmp[i].cols == n_points in function 'triangulatePoints'
The correct format is std::vector<cv::Mat>, where the std::vector has a size of n_views and the cv::Mat has 2 rows and n_points columns.
Steps to reproduce
#include <opencv4/opencv2/core/mat.hpp>
#include <opencv4/opencv2/sfm/triangulation.hpp>
#include <vector>
int main() {
const size_t n_views = 2;
const size_t n_keypoints = 3;
std::vector<std::vector<cv::Point2f>> points_2d(
n_views,
std::vector<cv::Point2f>(n_keypoints, cv::Point2f(100.0, 100.0)));
std::vector<cv::Mat> projection_matrices(n_views,
cv::Mat::zeros(3, 4, CV_32F));
cv::Mat points_3d;
cv::sfm::triangulatePoints(points_2d, projection_matrices, points_3d);
return 0;
}
Issue submission checklist
- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files: videos, images, onnx, etc