三次元復元を行おうとしている者なのですが、ORBで用いた特徴点を座標に変換するのに戸惑っています。
イテレータを使って特徴点の座標をvector<points2f>型に変換すればtriangulatePointsの2、3番目の引数に合致すると判断しているのですが間違えでしょうか。
またパターン1、パターン2を行ってもデバックエラーが表示されます。
<一部>(keypointsL,keypointsRはORBで所得した各左右座標の特徴点です)
<パターン1>
vector<Point2f>LeftImagePoints;
vector<Point2f>RightImagePoints;
vector<KeyPoint>::iterator itk;
for (auto itk = keypointsL.begin(); itk != keypointsL.end(); ++itk)
{
*itk;
LeftImagePoints.push_back(itk->pt);
}
for (auto itk = keypointsR.begin(); itk != keypointsR.end(); ++itk)
{
*itk;
RightImagePoints.push_back(itk->pt);
}
vector<Point3f>points3D;
Mat points4D;
double hbi = 40;
Mat cameraMatrixL =(Mat_<double>(3, 4) << 10, 0,0, 10 * hbi,0, 10, 30, 0,0, 0, 1, 0);
Mat cameraMatrixR =Mat_<double>(3, 4) << 10, 0, 20, 10 * -hbi,0, 10, 30, 0,0, 0, 1, 0);
triangulatePoints(cameraMatrixL, cameraMatrixR, Mat(LeftImagePoints), Mat(RightImagePoints), points4D);
convertPointsFromHomogeneous(points4D.reshape(4, 1), points3D);
<パターン2>
iteratorの部分を以下に変えてみた。
Mat points4D;
if (matches_good.size() > 5)
{
for (size_t i = 0; i <(int)matches_good.size(); ++i)
{ Mat ip(2, 1, CV_64FC1); Point2f p; ip.at<double>(0) = keypointsL[matches_good[i].queryIdx].pt.x; ip.at<double>(1) = keypointsL[matches_good[i].queryIdx].pt.y; p.x = ip.at<double>(0); p.y = ip.at<double>(1);
pointsL2D.push_back(p);
ip.at<double>(0) = keypointsR[matches_good[i].trainIdx].pt.x;
ip.at<double>(1) = keypointsR[matches_good[i].trainIdx].pt.y;
p.x = ip.at<double>(0);
p.y = ip.at<double>(1);
pointsR2D.push_back(p);
double hbi = 40;
Mat cameraMatrixL =(Mat_<double>(3, 4) << 10, 0, 20, 10 * hbi,0, 10, 30, 0,0, 0, 1, 0);
Mat cameraMatrixR =(Mat_<double>(3, 4) << 10, 0, 20, 10 * -hbi,0, 10, 30, 0,0, 0, 1, 0);