00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVKLTTRACKER_H
00026 #define QVKLTTRACKER_H
00027
00028 #include <GL/glew.h>
00029 #include <QVImage>
00030 #include <QGLPixelBuffer>
00031
00032 #include "v3d_gpuklt.h"
00033
00034 using namespace V3D_GPU;
00035
00042 class QVKLTTrackerFeature{
00043 private:
00044 QPointF position;
00045 float gain;
00046
00047 public:
00048 QVKLTTrackerFeature() { };
00049
00050 QVKLTTrackerFeature(float x, float y, float gain) {
00051 this->position = QPointF(x,y);
00052 this->gain = gain;
00053 }
00054
00055 void setGain (float gain){
00056 this->gain = gain;
00057 }
00058 void setPosition (float x, float y){
00059 this->position = QPointF(x,y);
00060 }
00061
00062 float getGain() const {
00063 return gain;
00064 }
00065
00066 QPointF getPosition() const{
00067 return position;
00068 };
00069 };
00070
00077 class QVKLTTracker
00078 {
00079 public:
00080
00081
00084 QVKLTTracker() { };
00085
00104 QVKLTTracker(int width, int height, bool trackWithGain=true,
00105 int featuresWidth=64, int featuresHeight=64,
00106 int nIterations=10, int nLevels=4, int levelSkip=1,int windowWidth=7,
00107 float trackBorderMargin=20.0f, float detectBorderMargin=20.0f,
00108 float convergenceThreshold=0.1f, float SSD_Threshold=5000.0f,
00109 int minDistance=7, float minCornerness=50.0f);
00110
00111
00112
00114 ~QVKLTTracker();
00115
00121 void detect (const QVImage<uChar,1> &image, QHash<int, QVKLTTrackerFeature> &features);
00122
00128 void redetect (const QVImage<uChar,1> &image, QHash<int, QVKLTTrackerFeature> &features);
00129
00135 void track (const QVImage<uChar,1> &image, QHash<int, QVKLTTrackerFeature> &features);
00136
00137 private:
00138 void updateHashTable( QHash<int,QVKLTTrackerFeature> &features,int width,int height);
00139
00140 KLT_SequenceTracker* tracker;
00141 KLT_TrackedFeature* feat;
00142 int* trackID;
00143 int nFeatures;
00144 int lastID;
00145 };
00146
00147 #endif // QVKLTTRACKER_H