I am new in the field of CV and trying to Triangulate Points between three Pictures but for the beginning, I want to Triangulate between two Pictures. For that, I made these Steps:
- Feature detection with AKAZE
- Feature matching by NORM_HAMMING
- Filter the Matches
- Match the filtered descriptors with the KeyPoint Coordinates
After that, I have a Vector of KeyPoints for each Image of the same size. Know i want to convert this Vector to "cv::Mat", so that i can use the TriangulatPoints function:
std::vector<cv::KeyPoint>::iterator it_1;
std::vector<cv::Point2f> points_1;
for(it_1 = keypoints_matched_1.begin() ; it_1!=keypoints_matched_1.end() ; it_1++)
{
points_1.push_back(it_1->pt);
}
cv::Mat pointmatrix1(points_1);
std::vector<cv::KeyPoint>::iterator it_2;
std::vector<cv::Point2f> points_2;
for(it_2 = keypoints_matched_2.begin() ; it_2!=keypoints_matched_2.end() ; it_2++)
{
points_2.push_back(it_2->pt);
}
cv::Mat pointmatrix2(points_2);
std::vector<cv::Mat> points3D;
std::vector<cv::Mat> points_all={pointmatrix1, pointmatrix2};
cv::sfm::triangulatePoints(points_all,Proj_matrices,points3D);
I keep running into this Error:
error: (-215:Assertion failed) points2d_tmp[i].rows == 2 && points2d_tmp[i].cols == n_points in function 'triangulatePoints'