• opencv单应矩阵


    #include "opencv2/opencv.hpp"
     
    using namespace cv;
    using namespace std;
     
    int main( int argc, char** argv)
    {
        // Read source image.
        Mat im_src = imread("book2.jpg");
        // Four corners of the book in source image
        vector<Point2f> pts_src;
        pts_src.push_back(Point2f(141, 131));
        pts_src.push_back(Point2f(480, 159));
        pts_src.push_back(Point2f(493, 630));
        pts_src.push_back(Point2f(64, 601));
     
     
        // Read destination image.
        Mat im_dst = imread("book1.jpg");
        // Four corners of the book in destination image.
        vector<Point2f> pts_dst;
        pts_dst.push_back(Point2f(318, 256));
        pts_dst.push_back(Point2f(534, 372));
        pts_dst.push_back(Point2f(316, 670));
        pts_dst.push_back(Point2f(73, 473));
     
        // Calculate Homography
        Mat h = findHomography(pts_src, pts_dst);
     
        // Output image
        Mat im_out;
        // Warp source image to destination based on homography
        warpPerspective(im_src, im_out, h, im_dst.size());
     
        // Display images
        imshow("Source Image", im_src);
        imshow("Destination Image", im_dst);
        imshow("Warped Source Image", im_out);
     
        waitKey(0);
    }
    #include "opencv2/opencv.hpp"
     
    using namespace cv;
    using namespace std;
     
    int main( int argc, char** argv)
    {
        // Read source image.
        Mat im_src = imread("book2.jpg");
        // Four corners of the book in source image
        vector<Point2f> pts_src;
        pts_src.push_back(Point2f(141, 131));
        pts_src.push_back(Point2f(480, 159));
        pts_src.push_back(Point2f(493, 630));
        pts_src.push_back(Point2f(64, 601));
     
     
        // Read destination image.
        Mat im_dst = imread("book1.jpg");
        // Four corners of the book in destination image.
        vector<Point2f> pts_dst;
        pts_dst.push_back(Point2f(318, 256));
        pts_dst.push_back(Point2f(534, 372));
        pts_dst.push_back(Point2f(316, 670));
        pts_dst.push_back(Point2f(73, 473));
     
        // Calculate Homography
        Mat h = findHomography(pts_src, pts_dst);
     
        // Output image
        Mat im_out;
        // Warp source image to destination based on homography
        warpPerspective(im_src, im_out, h, im_dst.size());
     
        // Display images
        imshow("Source Image", im_src);
        imshow("Destination Image", im_dst);
        imshow("Warped Source Image", im_out);
     
        waitKey(0);
    }
  • 相关阅读:
    一维函数指针数组和二维函数指针数组demo
    等着新工作
    SSRS常见问题解决方案
    速度
    javascript 满足多层treeview的各种勾选
    vue create 初步解析以及定制化修改
    leveldb总结
    秋招总结场景设计题
    NOSQL: mongoDB windows
    更新webconfig配置文件
  • 原文地址:https://www.cnblogs.com/yunshangyue71/p/13573322.html
Copyright © 2020-2023  润新知