double cameraMoved(cv::Mat prev, cv::Mat curr)
{
assert(1 == prev.channels() && 1 == curr.channels());
cv::Mat curr64f, prev64f, hann;
createHanningWindow(hann, prev.size(), CV_64F);
prev.convertTo(prev64f, CV_64F);
curr.convertTo(curr64f, CV_64F);
Point2d shift = phaseCorrelate(prev64f, curr64f, hann);
return std::sqrt(shift.x * shift.x + shift.y * shift.y);
{
assert(1 == prev.channels() && 1 == curr.channels());
cv::Mat curr64f, prev64f, hann;
createHanningWindow(hann, prev.size(), CV_64F);
prev.convertTo(prev64f, CV_64F);
curr.convertTo(curr64f, CV_64F);
Point2d shift = phaseCorrelate(prev64f, curr64f, hann);
return std::sqrt(shift.x * shift.x + shift.y * shift.y);
}
opencv 自带的 example 代码:
phase_corrlate.cpp
Video