【问题标题】:find homography matrix using openCV使用openCV找到单应矩阵
【发布时间】:2013-03-19 02:41:43
【问题描述】:

我正在 Visual Studio 2012 上使用 OpenCV 2.3.1 进行图像拼接项目。 由于未知原因,我的程序无法运行!

#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include <stdio.h>
#include <iostream>

       using namespace cv;
       using namespace std;
Mat getHomography() 
{

    vector<Point2f> points1;
    vector<Point2f> points2;

    points1.push_back(Point2f(10, 100));
    points1.push_back(Point2f(100, 10));
    points1.push_back(Point2f(200, 20));
    points1.push_back(Point2f(80, 30));

    points2.push_back(Point2f(220, 20));
    points2.push_back(Point2f(10, 220));
    points2.push_back(Point2f(90, 120));
    points2.push_back(Point2f(100, 20));

    Mat H = findHomography(Mat(points1), Mat(points2), 8, 3.0); 
    return H;
}

int main(){


    Mat HH = getHomography();
    cout<<HH;
    system("pause");

        return 0; 
}

我的问题: 任何帮助plzzz

【问题讨论】:

    标签: c++ opencv matrix


    【解决方案1】:

    每个 vec 至少需要 4 个点。 2 还不够

    【讨论】:

    • "getHompgraphy",呵呵,我喜欢,听起来不错:)
    • 你能告诉我如何显示这个矩阵 H 吗?
    • 哦,对不起,std::cout &lt;&lt; H &lt;&lt; std::endl;
    • #include &lt;stdlib.h&gt; 用于 system()。如果我使用cout&lt;&lt;H&lt;&lt;endl;,我会得到一个矩阵,如[-0.8181818181818187, -0.8181818181818414, 90.00000000000036; -1.090909090909092, -1.090909090909091, 119.9999999999999; -0.009090909090909094, -0.009090909090909177, 1]
    • 检查您链接的 opencv 库。对于调试,最后应该有一个“d”,而不是发布。如果您编译 32 位,请使用 opencv\build\x86\vc12\lib 中的库,用于 64 位 opencv\build\x64\vc12\lib 。并将您的 PATH 指向 opencv\build\x86\vc12\bin (或 x64 )
    【解决方案2】:

    我通过从 vs2012 更改为 vs 2010 解决了我的问题:D

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-30
      • 2014-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多