LiveFit
Track and plot projectiles for in-class demonstration
TrackingFilter.hpp
1 /*
2  * LiveFit
3  * Copyright (C) 2016 The University of Georgia
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef TRACKINGFILTER_HPP
21 #define TRACKINGFILTER_HPP
22 
23 #include "KalmanFilterPlus.hpp"
24 #include <QDebug>
25 
35 {
36 public:
38 
40  void flushKalman();
41 
61  double kalmanDistance(cv::Mat measurement);
62 
64  void updateTrackFailure();
65 
67  cv::Mat prediction();
69  cv::Mat covariance();
70 
72  void updateTimeState(double t);
73 
75  double dT() { return mTstop - mTstart; }
77  double time() { return mTstop; }
78 
80  bool isFound();
82  bool isLost();
83 
84 protected:
86  int mBlobRad;
88  int mLatency;
94 
98  cv::Mat mKfState;
101 
102  int mKfControlLen;
103  cv::Mat mKfControl;
104  cv::Mat mKfControlVec;
105 
109  cv::Mat mKfMeas;
110 
112  double mTstart = 0;
114  double mTstop = 0;
115 
118 };
119 
120 #endif // TRACKINGFILTER_HPP
int mNotFoundCount
Number of frames we have missed this object for.
Definition: TrackingFilter.hpp:93
cv::Mat prediction()
The KF prediction of the state.
Definition: TrackingFilter.cpp:49
double mTstart
Start time of this tick (the previous timestep&#39;s time)
Definition: TrackingFilter.hpp:112
double kalmanDistance(cv::Mat measurement)
Compute the Kalman distance to a measurement vector.
Definition: TrackingFilter.cpp:32
cv::Mat mKfState
State vector of most recent state.
Definition: TrackingFilter.hpp:98
int mKfMeasLen
Length of the measurement vector; 4 <x,y,w,h>
Definition: TrackingFilter.hpp:107
bool isLost()
Whether the object is lost and we don&#39;t know anything about it.
Definition: TrackingFilter.cpp:65
void updateTimeState(double t)
Update the time state of the tracker to the current time.
Definition: TrackingFilter.cpp:59
A cv::KalmanFilter which also supports some &#39;forgetful&#39; functionality.
Definition: KalmanFilterPlus.hpp:30
void updateTrackFailure()
Alert the KF that we did not track a ball this frame.
Definition: TrackingFilter.cpp:44
void flushKalman()
Reset KF state to initial values.
Definition: TrackingFilter.cpp:27
int mFoundCount
Number of frames we have tracked this object for.
Definition: TrackingFilter.hpp:100
int mBlobRad
Radius of the current state blob?
Definition: TrackingFilter.hpp:86
int mKfStateLen
Length of the state vector; 6 <x,y,dx,dy,w,h>
Definition: TrackingFilter.hpp:96
double time()
The current time state.
Definition: TrackingFilter.hpp:77
A wrapper around a KalmanFilter type object; additional logic can be provided through extension...
Definition: TrackingFilter.hpp:34
cv::Mat covariance()
The KF&#39;s covariance matrix.
Definition: TrackingFilter.cpp:54
int mLatency
Unused?
Definition: TrackingFilter.hpp:88
KalmanFilterPlus mKf
The Kalman Filter object proper.
Definition: TrackingFilter.hpp:117
bool isFound()
Whether we have found a object recently.
Definition: TrackingFilter.cpp:70
double mTstop
Stop time of this tick (the current timestate)
Definition: TrackingFilter.hpp:114
cv::Mat mKfMeas
Measurement vector of most recent state.
Definition: TrackingFilter.hpp:109
double dT()
Change in time from prior state to this one.
Definition: TrackingFilter.hpp:75