Align images based on a detected features in Opencv

穿精又带淫゛_ 提交于 2019-12-03 21:46:08

I remade your function without using the angles:

void rotate(cv::Mat& originalImage,cv::Mat& rotatedImage,cv::InputArray rotated,
cv::Mat& dst) {
    std::vector<cv::Point2f> original(4);
    original[0] = cv::Point( 0, 0);
    original[1] = cv::Point( originalImage.cols, 0 );
    original[2] = cv::Point( originalImage.cols, originalImage.rows );
    original[3] = cv::Point( 0, originalImage.rows );

    dst = cv::Mat::zeros(originalImage.rows, originalImage.cols, CV_8UC3);
    cv::Mat transform = cv::getPerspectiveTransform(rotated, original);
    cv::warpPerspective(rotatedImage, dst, transform, dst.size() );
}

Note that the input 'rotated' is in your case 'scene_corners' and 'dst' is the resulting image.

Hope that helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!