1
#include "opencv2/core/core.hpp"
2
#include "opencv2/videoio/videoio.hpp"
3
#include "opencv2/highgui/highgui.hpp"
4
#include "opencv2/imgproc/imgproc.hpp"
8
int main(int, char* [])
10
VideoCapture video(0);
11
Mat frame, curr, prev, curr64f, prev64f, hann;
17
cvtColor(frame, curr, COLOR_RGB2GRAY);
22
createHanningWindow(hann, curr.size(), CV_64F);
25
prev.convertTo(prev64f, CV_64F);
26
curr.convertTo(curr64f, CV_64F);
28
Point2d shift = phaseCorrelate(prev64f, curr64f, hann);
29
double radius = std::sqrt(shift.x*shift.x + shift.y*shift.y);
33
// draw a circle and line indicating the shift direction...
34
Point center(curr.cols >> 1, curr.rows >> 1);
35
circle(frame, center, (int)radius, Scalar(0, 255, 0), 3, LINE_AA);
36
line(frame, center, Point(center.x + (int)shift.x, center.y + (int)shift.y), Scalar(0, 255, 0), 3, LINE_AA);
39
imshow("phase shift", frame);
43
} while((char)key != 27); // Esc to exit...