我正在尝试使用OpenCV的videostab模块实现视频稳定。我需要在流中完成,因此我正在尝试获取两个帧之间的运动。在阅读文档后,我决定采用以下方式:
estimator = new cv::videostab::MotionEstimatorRansacL2(cv::videostab::MM_TRANSLATION);
keypointEstimator = new cv::videostab::KeypointBasedMotionEstimator(estimator);
bool res;
auto motion = keypointEstimator->estimate(this->firstFrame, thisFrame, &res);
std::vector<float> matrix(motion.data, motion.data + (motion.rows*motion.cols));
在这里,firstFrame
和thisFrame
是完全初始化的帧。问题在于,estimate
方法总是返回像这样的矩阵:
在这个矩阵中,只有最后一个值(matrix[8]
)从一帧到另一帧会发生变化。我是否正确地使用了videostab对象,以及如何将此矩阵应用于帧以获得结果?