diff --git a/FexTracker/FexTracker.h b/FexTracker/FexTracker.h new file mode 100644 index 000000000..681f22057 --- /dev/null +++ b/FexTracker/FexTracker.h @@ -0,0 +1,115 @@ + +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the FEXTRACKER_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// FEXTRACKER_API functions as being imported from a DLL, wheras this DLL sees symbols +// defined with this macro as being exported. +#ifdef FEXTRACKER_EXPORTS +#define FEXTRACKER_API __declspec(dllexport) +#else +#define FEXTRACKER_API __declspec(dllimport) +#endif + + + +class FEXTRACKER_API FexTrackerConfig +{ +public: + inline FexTrackerConfig() : + EdgeDetectSigma(1.f), + WindowX(3), WindowY(3), + SearchRange(15), + MaxIterations(10), + MinDeterminant(0.01f), + MinDisplacement(0.1f), + MaxResidue(10.f), + IgnoreLightning(0), + DetectSmoothSigma(0.9f), + MinDistanceSquare(100.f) + {}; + + int WindowX, WindowY; //static const int window_size = 7; + int SearchRange; + + float DetectSmoothSigma; //static const float pyramid_sigma_fact = 0.9f; + float EdgeDetectSigma; //static const float grad_sigma = 1.0f; + + int MaxIterations; //static const int max_iterations = 10; + float MinDeterminant; //static const float min_determinant = 0.01f; + float MinDisplacement; //static const float min_displacement = 0.1f; + float MaxResidue; //static const float max_residue = 10.0f; + + bool IgnoreLightning; //static const KLT_BOOL lighting_insensitive = FALSE; + + float MinDistanceSquare; //static const int mindist = 10; + + //static const int min_eigenvalue = 1; + //static const float smooth_sigma_fact = 0.1f; + //static const KLT_BOOL sequentialMode = FALSE; + ///* for affine mapping*/ + //static const int affineConsistencyCheck = -1; + //static const int affine_window_size = 15; + //static const int affine_max_iterations = 10; + //static const float affine_max_residue = 10.0; + //static const float affine_min_displacement = 0.02f; + //static const float affine_max_displacement_differ = 1.5f; +}; + +typedef struct{ + float x, y; +}vec2; + +class FexImgPyramid; +class FexTrackingFeature; + +class FEXTRACKER_API FexTracker +{ +public: + FexTracker( int sx, int sy, int nFeatures ); + ~FexTracker(); +//config + FexTrackerConfig Cfg; +//work + void ProcessImage( float *Img, bool bFirst=0 ); //we assume grayscale image here + + FexTrackingFeature* operator [] ( int i ); + inline int GetCount(){ return nFeatures; }; + inline int GetFrame(){ return CurFrame; }; + + bool bDebug; + int minFeatures; +private: + int SizX, SizY; + int PyramidSubsampling; + int PyramidMaxLevels; + FexImgPyramid* CurImg; + FexImgPyramid* NextImg; + + void FindFeatures( int minFeatures ); + void TrackFeatures(); + + bool TrackOneFeature( int lvl, vec2 op, vec2& np ); + int GetEigenvalueForPoint( int px, int py ); + void GetDiffForPointset( int lvl, vec2 op, vec2 np, float* diff ); + void GetGradForPointset( int lvl, vec2 op, vec2 np, float* gradx, float* grady ); + + void CountActiveFeatures(); + +//result + FexTrackingFeature* lFeatures; + int nFeatures; + int nActiveFeatures; + int mFeatures; + + int CurFrame; +}; + + + +FEXTRACKER_API void FexBaseResize( float* out, int newx, int newy, float* in, int sizx, int sizy ); +FEXTRACKER_API void GaussKernelWidths( float sigma, int *gauss_width, int *gaussderiv_width ); +FEXTRACKER_API void GaussEdgeDetect( float* Img, int sizx, int sizy, float sigma, float* GradX, float* GradY ); +FEXTRACKER_API void GaussSmooth( float* Img, int sizx, int sizy, float sigma, float* Out ); + + diff --git a/FexTracker/FexTrackerRel.dll b/FexTracker/FexTrackerRel.dll new file mode 100644 index 000000000..513309c08 Binary files /dev/null and b/FexTracker/FexTrackerRel.dll differ diff --git a/FexTracker/FexTrackerRel.lib b/FexTracker/FexTrackerRel.lib new file mode 100644 index 000000000..17dbb531e Binary files /dev/null and b/FexTracker/FexTrackerRel.lib differ diff --git a/FexTracker/FexTrackerRel_Opti.dll b/FexTracker/FexTrackerRel_Opti.dll new file mode 100644 index 000000000..8cef0000b Binary files /dev/null and b/FexTracker/FexTrackerRel_Opti.dll differ diff --git a/FexTracker/FexTrackerRel_Opti.lib b/FexTracker/FexTrackerRel_Opti.lib new file mode 100644 index 000000000..910ca934b Binary files /dev/null and b/FexTracker/FexTrackerRel_Opti.lib differ diff --git a/FexTracker/FexTrackingFeature.h b/FexTracker/FexTrackingFeature.h new file mode 100644 index 000000000..90bbbce75 --- /dev/null +++ b/FexTracker/FexTrackingFeature.h @@ -0,0 +1,25 @@ +// FexTrackingFeature.h: interface for the FexTrackingFeature class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_FEXTRACKINGFEATURE_H__23B42013_9F11_467C_A0F6_F9E647D45CEB__INCLUDED_) +#define AFX_FEXTRACKINGFEATURE_H__23B42013_9F11_467C_A0F6_F9E647D45CEB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "tenlist.h" +class FexTrackingFeature +{ +public: + FexTrackingFeature(); + ~FexTrackingFeature(); + + int Eigenvalue; + tenlist Pos; + + int StartTime; +}; + +#endif // !defined(AFX_FEXTRACKINGFEATURE_H__23B42013_9F11_467C_A0F6_F9E647D45CEB__INCLUDED_) diff --git a/FexTracker/tenlist.h b/FexTracker/tenlist.h new file mode 100644 index 000000000..1bbd0029e --- /dev/null +++ b/FexTracker/tenlist.h @@ -0,0 +1,65 @@ +#pragma once + +template< class type > + class tenlist { +public: + int nVal; + int mVal; + type* lVal; + + inline tenlist() + { + mVal = 0; + nVal = 0; + lVal = 0; + //zero everything since we well over-zero it anyway + } + inline ~tenlist() + { + free( lVal ); + } + + inline int size() + { + return nVal; + } + + inline void Add( type t ) + { + if( nVal+1 >= mVal ) + { + mVal += 8; + lVal = (type*)realloc( lVal, sizeof(type)*mVal ); + memset( lVal+nVal, 0x00, sizeof(type)*(mVal-nVal) ); //lVal+nVal, since it'll be multiplied by sizeof(type) due to lVal being a type* + } + lVal[nVal++] = t; + } + + inline void AddStr( type t ) + { + if( nVal+1 >= mVal ) + { + mVal += 8; + lVal = (type*)realloc( lVal, sizeof(type)*mVal ); + memset( lVal+nVal, 0x00, sizeof(type)*(mVal-nVal) ); //lVal+nVal, since it'll be multiplied by sizeof(type) due to lVal being a type* + } + strcpy( lVal[nVal++], t ); + } + + inline void Rem( int n ) + { + if( n>=nVal ) + { + nVal = 0; + return; + } + + for( int i=0;i