liz*_*isk 4 opencv image-processing computer-vision homography affinetransform
我试图通过匹配SIFT描述符并通过RANSAC查找转换矩阵来搜索输入图像中的特定对象.该对象只能通过2D空间中的相似变换(缩放,旋转,平移)在场景中进行修改,因此我需要在3D空间中估计2x2变换矩阵而不是3x3单应矩阵.我怎样才能在OpenCV中实现这一目标?
您可以使用estimateRigidTransform(我不知道它是否是RANSAC,代码位于http://code.opencv.org/projects/opencv/repository/revisions/2.4.4/entry/modules/video/src/lkpyramid.cpp RANSAC在其评论中说,第三个参数设置为false
只获得比例+旋转+翻译:
#include <vector>
#include <iostream>
#include "opencv2/video/tracking.hpp"
int main( int argc, char** argv )
{
std::vector<cv::Point2f> p1s,p2s;
p1s.push_back(cv::Point2f( 1, 0));
p1s.push_back(cv::Point2f( 0, 1));
p1s.push_back(cv::Point2f(-1, 0));
p1s.push_back(cv::Point2f( 0,-1));
p2s.push_back(cv::Point2f(1+sqrt(2)/2, 1+sqrt(2)/2));
p2s.push_back(cv::Point2f(1-sqrt(2)/2, 1+sqrt(2)/2));
p2s.push_back(cv::Point2f(1-sqrt(2)/2, 1-sqrt(2)/2));
p2s.push_back(cv::Point2f(1+sqrt(2)/2, 1-sqrt(2)/2));
cv::Mat t = cv::estimateRigidTransform(p1s,p2s,false);
std::cout << t << "\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
使用OpenCV 2.4.4编译和测试.输出是:
[0.7071067988872528, -0.7071067988872528, 1.000000029802322;
0.7071067988872528, 0.7071067988872528, 1.000000029802322]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11310 次 |
最近记录: |