You can use estimateRigidTransform (I don't know if this is RANSAC, the code http://code.opencv.org/projects/opencv/repository/revisions/2.4.4/entry/modules/video/src/lkpyramid.cpp says RANSAC in your comment), the third parameter is set to false to get just the 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"; return 0; }
compiled and tested with OpenCV 2.4.4. Output:
[0.7071067988872528, -0.7071067988872528, 1.000000029802322; 0.7071067988872528, 0.7071067988872528, 1.000000029802322]
source share