OpticalFlow.h
Go to the documentation of this file.00001 #ifndef OPTICAL_FLOW_H
00002 #define OPTICAL_FLOW_H
00003
00004 #include "Shared/fmat.h"
00005 #include "DualCoding/ShapeLine.h"
00006
00007 #include "RawImagePyramid.h"
00008
00009 using namespace std;
00010
00011 class ScorePoint {
00012 public:
00013 ScorePoint() : position(fmat::pack(0,0)), score(0.0f) {}
00014
00015 fmat::Column<2> position;
00016 float score;
00017 };
00018
00019 class FlowVector {
00020
00021 public:
00022 FlowVector() : position(fmat::pack(0,0)), flow(fmat::pack(0,0)), relevanceScore(0) {}
00023
00024 fmat::Column<2> position;
00025 fmat::Column<2> flow;
00026
00027 float relevanceScore;
00028 };
00029
00030 class OpticalFlow {
00031
00032 public:
00033
00034 static const unsigned int SCORE_LAYER = 0;
00035
00036 static const unsigned int NUM_FLOW_VECTORS = 50;
00037
00038
00039
00040
00041 static const unsigned int FLOW_WINDOW = 2;
00042
00043
00044
00045
00046 static const unsigned int SCORE_WINDOW = 1;
00047
00048
00049 static const unsigned int NUM_FRAMES = 10;
00050
00051
00052 static const unsigned int CANDIDATE_FEATURE_RESOLUTION = 30;
00053
00054 OpticalFlow();
00055 OpticalFlow(OpticalFlow &other);
00056
00057 virtual ~OpticalFlow() {};
00058
00059
00060 static bool myFlowComp(const FlowVector &v1, const FlowVector &v2);
00061
00062
00063 static bool myFlowComp2(const FlowVector &v1, const FlowVector &v2);
00064
00065 static bool scoreComp(const ScorePoint &p1, const ScorePoint &p2) {
00066 return p2.score < p1.score;
00067 }
00068
00069
00070 void updateFlow();
00071
00072
00073 void drawFlow();
00074
00075 void swapPyramids();
00076
00077
00078
00079
00080
00081 void initializePositions();
00082
00083 float getIntegratedFlow() { return integratedFlow; }
00084
00085
00086
00087
00088
00089 void computeRelevanceScores();
00090
00091
00092 static fmat::Column<2>
00093 iterativeLucasKanade(fmat::Column<2> center, fmat::Column<2> trans,
00094 RawImage& img1, RawImage& img2, int window);
00095
00096 protected:
00097 float integratedFlow;
00098
00099 private:
00100 std::vector<FlowVector> flowVectors;
00101 std::vector<DualCoding::Shape<DualCoding::LineData> > flowVectorVisuals;
00102 std::vector<float> pastTranslations;
00103
00104 OpticalFlow & operator=(const OpticalFlow &other);
00105
00106 RawImagePyramid pyramid1;
00107 RawImagePyramid pyramid2;
00108 RawImagePyramid *currPyramid;
00109 RawImagePyramid *prevPyramid;
00110 };
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 #endif