Go to the documentation of this file.00001
00029 #ifndef ORIENTATIONINTERPRETER_H
00030 #define ORIENTATIONINTERPRETER_H
00031
00032 #include <QObject>
00033 #include <QFile>
00034 #include "filter.h"
00035 #include <datatypes/orientationdata.h>
00036 #include <datatypes/posedata.h>
00037
00045 class OrientationInterpreter : public QObject, public FilterBase
00046 {
00047 Q_OBJECT;
00048
00049 Q_PROPERTY(PoseData orientation READ orientation);
00050
00051 private:
00052 Sink<OrientationInterpreter, AccelerationData> accDataSink;
00053 Source<PoseData> topEdgeSource;
00054 Source<PoseData> faceSource;
00055 Source<PoseData> orientationSource;
00056
00057 void accDataAvailable(unsigned, const AccelerationData*);
00058
00059 bool overFlowCheck();
00060 void processTopEdge();
00061 void processFace();
00062 void processOrientation();
00063 void solveTopEdge();
00064
00065 OrientationInterpreter();
00066
00067 PoseData topEdge;
00068 PoseData newTopEdge;
00069 PoseData face;
00070
00071 AccelerationData data;
00072 QList<AccelerationData> dataBuffer;
00073
00074 int minLimit;
00075 int maxLimit;
00076 int angleThresholdPortrait;
00077 int angleThresholdLandscape;
00078 int faceThreshold;
00079 unsigned long discardTime;
00080 int maxBufferSize;
00081
00082 PoseData orientationData;
00083
00084 QFile cpuBoostFile;
00085
00086 enum OrientationMode
00087 {
00088 Portrait = 0,
00089 Landscape
00090 };
00091
00092 PoseData rotateToLandscape(int);
00093 PoseData rotateToPortrait(int);
00094 int orientationCheck(const AccelerationData&, OrientationMode) const;
00095 PoseData orientationRotation(const AccelerationData&, OrientationMode, PoseData (OrientationInterpreter::*)(int));
00096
00097 static const float RADIANS_TO_DEGREES;
00098 static const int SAME_AXIS_LIMIT;
00099
00100 static const int OVERFLOW_MIN;
00101 static const int OVERFLOW_MAX;
00102
00103 static const int THRESHOLD_LANDSCAPE;
00104 static const int THRESHOLD_PORTRAIT;
00105 static const int THRESHOLD_FACE;
00106
00107 static const int DISCARD_TIME;
00108 static const int AVG_BUFFER_MAX_SIZE;
00109
00110 static const char* CPU_BOOST_PATH;
00111
00112 public:
00117 static FilterBase* factoryMethod()
00118 {
00119 return new OrientationInterpreter();
00120 }
00121
00122 PoseData orientation() const { return orientationData; }
00123 };
00124
00125 #endif