image processing - How to estimate 2D similarity transformation (linear conformal, nonreflective similarity) in OpenCV? -
i'm trying search specific object in input images matching sift descriptors , finding transformation matrix ransac. object can modified in scene similarity transform in 2d space (scaled, rotated, translated), need estimate 2x2 transform matrix instead of 3x3 homography matrix in 3d space. how can accomplish in opencv?
you can utilize estimaterigidtransform (i not know whether ransac, code @ http://code.opencv.org/projects/opencv/repository/revisions/2.4.4/entry/modules/video/src/lkpyramid.cpp says ransac in comment), 3rd parameter set false
in order scale+rotation+translation:
#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"; homecoming 0; }
compiled , tested opencv 2.4.4. output is:
[0.7071067988872528, -0.7071067988872528, 1.000000029802322; 0.7071067988872528, 0.7071067988872528, 1.000000029802322]
opencv image-processing computer-vision affinetransform homography
No comments:
Post a Comment