My Project
TrackerFeatures.h
Go to the documentation of this file.
1 /*
2  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
3  *
4  * Copyright 2007-2012 VTT Technical Research Centre of Finland
5  *
6  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
7  * <http://www.vtt.fi/multimedia/alvar.html>
8  *
9  * ALVAR is free software; you can redistribute it and/or modify it under the
10  * terms of the GNU Lesser General Public License as published by the Free
11  * Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with ALVAR; if not, see
21  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
22  */
23 
24 #ifndef TRACKERFEATURES_H
25 #define TRACKERFEATURES_H
26 
33 #include "Tracker.h"
34 
35 namespace alvar {
36 
40 class ALVAR_EXPORT TrackerFeatures : public Tracker
41 {
42 protected:
43  int x_res, y_res;
44  int frame_count;
45  double quality_level;
46  double min_distance;
47  int min_features;
48  int max_features;
49  cv::Mat status;
50  cv::Mat img_eig;
51  cv::Mat img_tmp;
52  cv::Mat gray;
53  cv::Mat prev_gray;
54  cv::Mat pyramid;
55  cv::Mat prev_pyramid;
56  cv::Mat mask;
57  int next_id;
58  int win_size;
59  int pyr_levels;
60 
62  double TrackHid(const cv::Mat &img, cv::Mat &mask, bool add_features = true);
63 
64 public:
66  std::vector<cv::Point2f>
67  prev_features; // this used to be an array of points now, its an array of Matrices? -Sebastian
69  std::vector<cv::Point2f>
70  features; // this used to be an array of points now, its an array of Matrices? -Sebastian
76  int *prev_ids;
78  int *ids;
88  TrackerFeatures(int _max_features = 100,
89  int _min_features = 90,
90  double _quality_level = 0.01,
91  double _min_distance = 10,
92  int _pyr_levels = 1,
93  int _win_size = 3);
97  void ChangeSettings(int _max_features = 100,
98  int _min_features = 90,
99  double _quality_level = 0.01,
100  double _min_distance = 10);
102  void Reset();
104  double Reset(const cv::Mat &img, cv::Mat &mask);
106  bool DelFeature(int index);
108  bool DelFeatureId(int id);
110  double
111  Track(cv::Mat &img)
112  {
113  return Track(img, true);
114  }
116  double Track(cv::Mat &img, bool add_features);
118  double Track(cv::Mat &img, cv::Mat &mask);
120  int AddFeatures(cv::Mat &mask);
122  cv::Mat NewFeatureMask();
127  int Purge();
128 };
129 
130 } // namespace alvar
131 
132 #endif
This file implements a tracking interface.
TrackerFeatures tracks features using OpenCV's cvGoodFeaturesToTrack and cvCalcOpticalFlowPyrLK
std::vector< cv::Point2f > prev_features
Track result: previous features
TrackerFeatures(int _max_features=100, int _min_features=90, double _quality_level=0.01, double _min_distance=10, int _pyr_levels=1, int _win_size=3)
int Purge()
Purge features that are considerably closer than the defined min_distance.
bool DelFeatureId(int id)
Stop tracking the identified feature (with feature id)
void ChangeSettings(int _max_features=100, int _min_features=90, double _quality_level=0.01, double _min_distance=10)
Change settings while running.
bool DelFeature(int index)
Stop tracking the identified feature (with index for features array)
double Track(cv::Mat &img, bool add_features)
Track features.
int * prev_ids
Track result: ID:s for previous features
int * ids
Track result: ID:s for current features
cv::Mat NewFeatureMask()
Create and get the pointer to new_features_mask.
double Reset(const cv::Mat &img, cv::Mat &mask)
Reset track features on specified mask area.
int feature_count
Track result: count of current features
double Track(cv::Mat &img)
Track features.
double Track(cv::Mat &img, cv::Mat &mask)
Track features.
int AddFeatures(cv::Mat &mask)
add features to the previously tracked frame if there are less than min_features
~TrackerFeatures()
Destructor.
int prev_feature_count
Track result: count of previous features
double TrackHid(const cv::Mat &img, cv::Mat &mask, bool add_features=true)
Reset track features on specified mask area.
std::vector< cv::Point2f > features
Track result: current features
Pure virtual base class for tracking optical flow.
Definition: Tracker.h:45
Main ALVAR namespace.
Definition: Alvar.h:174