25 #ifndef __Tracker_hh__
26 #define __Tracker_hh__
27 #include <Base/Common/BIASpragmaStart.hh>
31 #include <Base/Math/Vector.hh>
32 #include <Base/Geometry/HomgPoint2D.hh>
33 #include <Image/PyramidImageInterface.hh>
34 #include <Filter/GradientSobel3x3.hh>
35 #include <Filter/GradientGauss.hh>
36 #include <Filter/GradientGaussAsymmetric.hh>
37 #include <Filter/Gauss.hh>
38 #include <Filter/Mean.hh>
39 #include <Filter/FilterMask.hh>
41 #include "TrackerBaseInterface.hh"
45 #define D_TRACKER_INIT 0x00000001
46 #define D_TRACKER_TRACK 0x00000002
47 #define D_TRACKER_PARAM 0x00000004
48 #define D_TRACKER_WRITE_IM 0x00000008
49 #define D_TRACKER_FILL_UP 0x00000010
50 #define D_TRACKER_IMAGES 0x00000020
51 #define D_TRACKER_NUMITER 0x00000040
52 #define D_TRACKER_ERROR 0x00000080
71 template <
class StorageType,
class CalculationType>
121 int FillUpPoints(
const std::vector<HomgPoint2D>& points,
122 const std::vector<float>& qual);
128 int ReplacePoints(
const std::vector<HomgPoint2D>& points,
129 const std::vector<float>& qual);
134 int ReplaceAllPoints(
const std::vector<HomgPoint2D>& points,
135 const std::vector<float>& qual);
178 const std::vector<HomgPoint2D>& prediction,
190 const std::vector<HomgPoint2D>& prediction,
214 inline void GetPoints(std::vector<HomgPoint2D>& p)
const
215 { p = Points_[PyIndex_]; }
221 { numiter = NumIter_[PyIndex_]; }
226 inline void GetError(std::vector<double>& error)
const
227 { error = DisplInLastIter_[PyIndex_]; }
233 { residui = ResiduiMAD_[PyIndex_]; }
239 { residui = ResiduiMSD_[PyIndex_]; }
253 { results = res_[PyIndex_]; }
257 results = AffineResults_[PyIndex_];
263 { cov = Cov_[PyIndex_]; }
274 int WriteTrackFile(std::deque<std::vector<HomgPoint2D> >& p,
275 std::deque<std::vector<int> >& results,
276 const std::string& name);
285 int GetTrackerType();
287 void SetTrackerType(
int tracker_type);
293 { tb_->SetRejectionType(rejection_type); }
296 tb_->SetAffineBrightnessInvariance(bi);
300 {
return HalfWinSize_; }
303 { HalfWinSize_ = hws; }
306 { WeightMatrices_ = matrices; }
309 { MaxError_ = max_error; }
317 { MaxResiduumMAD_=maxres; }
320 { MaxIter_ = max_iter; }
323 UseCoarserPointIfLost_ = UseCoarse;
338 Vector2FilterMask_(vec, fm, separable);
343 Vector2FilterMask_(vec, fm, separable);
348 Vector2FilterMask_(vec, fm, separable);
356 const int pysize = (int)LastImage_->size()-1;
357 const int maxf = (int)Points_[PyIndex_].size();
359 const int pyind=PyIndex_;
360 for (
int i=0; i<maxf; i++){
361 os << std::setw(5) << i <<
" : ";
362 for (
int p=pysize; p>=pyind; p--){
363 os <<
" " << Points_[p][i] << std::setw(4) << res_[p][i];
393 std::vector<std::vector<int> >
res_;
397 std::vector<std::vector<HomgPoint2D> >
Points_;
407 std::vector<std::vector<Matrix<double> > >
Cov_;
422 void ResizeInternals_(
const int pysize);
427 void ResizeInternals_(
const int pysize,
const int num_points);
430 void ReserveInternals_(
const int pysize,
const int pointsize);
434 void PadPoints_(
const int start);
437 void WriteTrackLog_(
int num);
439 void DetermineROI_(
int &tlx,
int &tly,
int &brx,
int &bry)
const ;
445 #include <Base/Common/BIASpragmaEnd.hh>
447 #endif // __Tracker_hh__
ETrackerType
defines type or combination of tracker(s) used: simple/weighted estimate a dx,dy, Affine estimate an ...
std::vector< HomgPoint2D > p2tracked_
temporary data
void GetResiduiMSD(std::vector< double > &residui) const
returns the squared mean grey level difference in the tracking window on the biggest pyramid level...
void DumpResults(std::ostream &os=std::cout)
Vector< int > MaxIter_
the parameter
void SetMaxIterations(const Vector< int > &max_iter)
void SetWeightMatrix(const std::vector< Matrix< KLT_TYPE > > &matrices)
const Vector< int > & GetHalfWinSize()
std::vector< std::vector< double > > ResiduiMSD_
mean squared grey level difference (MSD) in tracking window
std::vector< Matrix2x2< double > > AffinePrediction_
prediction for affine warping, same for all pyramid levels
void GetResiduiMAD(std::vector< double > &residui) const
returns the mean grey level difference in the tracking window on the biggest pyramid level...
void GetResults(std::vector< int > &results) const
returns the results from the base tracker class on the biggest pyramid level.
TrackerBaseInterface< CalculationType > * tb_
the base tracker
PyramidImageInterface< CalculationType > * LastImage_
std::vector< std::vector< HomgPoint2D > > Points_
the point position in the actual image
bool UseCoarserPointIfLost_
set if you want to keep track of points regardless of trackability in highest resolution ...
Vector< KLT_TYPE > MaxError_
void SetCoarsePointUsage(const bool &UseCoarse)
void GetNumIter(std::vector< int > &numiter) const
returns the number of iterations used in the biggest pyramid level
Vector< int > HalfWinSize_
void SetGradYMask(const FilterMask &mask)
PyramidImageInterface< CalculationType > * LastGradY_
std::vector< std::vector< int > > res_
result code for every point
void SetMaxResiduumMAD(const Vector< KLT_TYPE > &maxres)
!!! Also used for X84M as maximal residuum.
void GetCovariances(std::vector< Matrix< double > > &cov) const
returns covariance matrices for biggest pyramid level.
void SetHalfWinSize(const Vector< int > &hws)
std::vector< std::vector< double > > ResiduiMAD_
mean absolute grey level difference (MAD) in tracking window
std::vector< std::vector< Matrix2x2< double > > > AffineResults_
results of affine tracking
void SetGradXMask(Vector< double > &vec, bool separable)
void SetGradYMask(Vector< double > &vec, bool separable)
void SetLowpassMask(const FilterMask &mask)
std::vector< std::vector< HomgPoint2D > > PredictedPoints_
the prediction for every pyramid image
void GetAffineEstimates(std::vector< Matrix2x2< double > > &results)
returns estimated affine matrices
void GetError(std::vector< double > &error) const
returns the displacement in the last iteration on the biggest pyramid level.
void SetGradXMask(const FilterMask &mask)
void SetAffineBrightnessInvariance(bool bi)
void SetMaxError(const Vector< double > &max_error)
The image template class for specific storage types.
FilterNTo2N< CalculationType, CalculationType > * grad_
the gradient filter
std::vector< BIAS::Matrix< KLT_TYPE > > WeightMatrices_
std::vector< std::vector< Matrix< double > > > Cov_
covariance matrices
void GetPoints(std::vector< HomgPoint2D > &p) const
returns the point positions in the actual image points at infinity (w=0.0) are returned, if tracking failed
void SetLowpassMask(Vector< double > &vec, bool separable)
std::vector< std::vector< double > > DisplInLastIter_
displacement inlast iteration
FilterNToN< StorageType, CalculationType > * lowpass_
the lowpass filter
void SetRejectionType(int rejection_type)
Vector< KLT_TYPE > MaxResiduumMAD_
A filter mask (or a kernel) used for convolution.
High level tracking class.
std::vector< std::vector< int > > NumIter_
number of iterations used