Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

a quick look at the docs reveals, that it takes vector<Point2f> as input, not vector<KeyPoint> . so both your arrays, when checked, return -1 here and get rejected.

using Point2f , it should work:

int npoints = 10;
int dx = 25;
std::vector<Point2f> P0, P1;
for (int n = 0; n < npoints; n++) {

    Point2f p((float)n, (float)n);
    P0.push_back(p);
    p.x += dx;
    P1.push_back(p);
}

cv::videostab::MotionModel model = cv::videostab::MM_TRANSLATION;
cv::Ptr<cv::videostab::MotionEstimatorRansacL2> MotionEstimator = cv::makePtr<cv::videostab::MotionEstimatorRansacL2>(model);

bool estimationOK;
cv::Mat M = MotionEstimator->estimate(P1, P0, &estimationOK);
cout << estimationOK << M << endl;

1[1, 0, -25;
 0, 1, 0;
 0, 0, 1]