| 287 |
Kevin |
1 |
//#include "opencv2/highgui/highgui.hpp"
|
|
|
2 |
//#include "opencv2/video/tracking.hpp"
|
|
|
3 |
//#include <Windows.h>
|
|
|
4 |
//#include "KalmanFilter.h"
|
|
|
5 |
//
|
|
|
6 |
//#define drawCross( center, color, d ) \
|
|
|
7 |
// line(img, cv::Point(center.x - d, center.y - d), cv::Point(center.x + d, center.y + d), color, 2, CV_AA, 0); \
|
|
|
8 |
// line(img, cv::Point(center.x + d, center.y - d), cv::Point(center.x - d, center.y + d), color, 2, CV_AA, 0)
|
|
|
9 |
//
|
|
|
10 |
//using namespace std;
|
|
|
11 |
//
|
|
|
12 |
//int main() {
|
|
|
13 |
//
|
|
|
14 |
// char code = (char)-1;
|
|
|
15 |
// POINT mousePos;
|
|
|
16 |
// GetCursorPos(&mousePos);
|
|
|
17 |
//
|
|
|
18 |
// KalmanFilter KF(mousePos.x, mousePos.y);
|
|
|
19 |
//
|
|
|
20 |
// // Image to show mouse tracking
|
|
|
21 |
// cv::Mat img(600, 800, CV_8UC3);
|
|
|
22 |
// vector<cv::Point> mousev, kalmanv;
|
|
|
23 |
// mousev.clear();
|
|
|
24 |
// kalmanv.clear();
|
|
|
25 |
//
|
|
|
26 |
// while (1) {
|
|
|
27 |
// KF.predict();
|
|
|
28 |
//
|
|
|
29 |
// // Get mouse point
|
|
|
30 |
// GetCursorPos(&mousePos);
|
|
|
31 |
//
|
|
|
32 |
// cv::Point measPt = cv::Point(mousePos.x, mousePos.y);
|
|
|
33 |
// cv::Point statePt = KF.correct(mousePos.x, mousePos.y);
|
|
|
34 |
//
|
|
|
35 |
// // plot points
|
|
|
36 |
// imshow("mouse kalman", img);
|
|
|
37 |
// img = cv::Scalar::all(0);
|
|
|
38 |
//
|
|
|
39 |
// mousev.push_back(measPt);
|
|
|
40 |
// kalmanv.push_back(statePt);
|
|
|
41 |
// drawCross(statePt, cv::Scalar(255, 255, 255), 5);
|
|
|
42 |
// drawCross(measPt, cv::Scalar(0, 0, 255), 5);
|
|
|
43 |
//
|
|
|
44 |
// for (int i = 0; i < mousev.size() - 1; i++)
|
|
|
45 |
// line(img, mousev[i], mousev[i + 1], cv::Scalar(255, 255, 0), 1);
|
|
|
46 |
//
|
|
|
47 |
// for (int i = 0; i < kalmanv.size() - 1; i++)
|
|
|
48 |
// line(img, kalmanv[i], kalmanv[i + 1], cv::Scalar(0, 155, 255), 1);
|
|
|
49 |
//
|
|
|
50 |
// code = (char)cv::waitKey(100);
|
|
|
51 |
// if (code > 0)
|
|
|
52 |
// break;
|
|
|
53 |
// }
|
|
|
54 |
//
|
|
|
55 |
// return 0;
|
|
|
56 |
//}
|