我们正在尝试不断地处理两个相机捕获的图像帧,每两帧处理一次,然后将它们拼接以获得完整的视图。为了做到这一点,我们有 1.extracted surf 特征。2.使用 Flann Matcher 得到两个图像之间的匹配。3.使用这些匹配计算单应矩阵。4.在右图上应用warpPerspective。
//To get the surf keypoints and descriptors:
cuda::SURD_CUDA surf(700);
surf(leftImgGpu, cuda::GpuMat(), keyPointsGpuA, descriptorsAGpu);
surf(rightImgGpu, cuda::GpuMat(), keyPointsGpuB, descriptorsBGpu);
surf.downloadKeypoints(keypointsAGpu, keypoiintsA);
surf.downloadKeypoints(keypointsBGpu, keypoiintsB);
//Flann based matcher:
FlannBasedMatcher matcher(new cv::flann::KDTreeIndexParams(4), new
cv::flann::SearchParams())
//To get the homography matrix:
vector<Point2f> imgPtsA, imgPtsB;
for(int i=0;i<matches.size();i++){
imgPtsB.push_back(keypointsB[matches[i].queryIdx].pt);
imgPtsA.push_back(keypointsA[matches[i].trainIdx].pt);
}
Mat H=findHomography(imgPtsA, imgPtsB, CV_RANSAC);
//To a warp right image:
warpPerspective(rightImg, warpRight, H, rightImg.size());
我们有两个问题: 问题 1:扭曲的图像3正在移动。左右摄像头是固定的,我们正在处理的图像(左、右)每次都几乎相同。我们怀疑匹配和单应矩阵存在一些问题,因为扭曲的图像没有正确出现。问题 2:我们最初使用 BF Matcher 来获取匹配项。当使用这些匹配构建 Homography 垫时,我们得到了奇怪的结果。使用基于 Flann 的匹配器后,结果相对更好。