1

我正在尝试通过将帧 n-1 与帧 n 缝合来从视频中创建全景图。我的问题是,在(大约 20 帧)之后,图片的右侧变得非常模糊,我不知道该怎么处理它。

主要的:

  frames = getVideoFrames();
  stichPair(frames[1], frames[0], panorama[0]);
    for (int i = 2; i < SIZE; i++)
    {
        stichPair(frames[i], panorama[i - 2], panorama[i - 1]);
        printf("%d\n", i);
    }

    cvNamedWindow(windowsName1, 1);
    on_trackbar(index, 0);
    createTrackbar("MyTrackbar:", windowsName1, &index, SIZE - 2, on_trackbar);

针对:

Ptr<FeatureDetector> brisk = BRISK::create(20, 3, 1.0f);
    Ptr<DescriptorMatcher> matcher = BFMatcher::create("BruteForce-Hamming");
// find features
    brisk->detect(leftImage, keypoints_1);
    brisk->detect(rightImage, keypoints_2);
    brisk->compute(leftImage, keypoints_1, descriptors_1);
    brisk->compute(rightImage, keypoints_2, descriptors_2);

    // Find two nearest matches
    matcher->knnMatch(descriptors_1, descriptors_2, matches, 2);

    //filter bad matches
    const float ratio = 0.6;
    for (int i = 0; i < matches.size(); ++i)
    {
        if (matches[i][0].distance / matches[i][1].distance < ratio)
        {
            good_matches.push_back(matches[i][0]);
        }
    }

    for (size_t i = 0; i < good_matches.size(); i++)
    {
        leftImage_matchedKPs.push_back(keypoints_1[good_matches[i].queryIdx].pt);
        rightImage_matchedKPs.push_back(keypoints_2[good_matches[i].trainIdx].pt);
    }

    H = findHomography(Mat(rightImage_matchedKPs), Mat(leftImage_matchedKPs), RANSAC, 5);
    warpPerspective(rightImage, rightImageWarped, H, Size(4000, 1280)); // fixed size

    panorama = rightImageWarped.clone();
    roi = Mat(panorama, Rect(0, 0, leftImage.cols, leftImage.rows));
    leftImage.copyTo(roi);
}

20帧后

40帧后

4

0 回答 0