00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00074 #ifndef _THREETOTWODIMCALC_H
00075 #define _THREETOTWODIMCALC_H
00076 #include <OpenTracker/dllinclude.h>
00077 #if USE_THREETOTWODIMFILTER
00078
00079 #include <OpenTracker/otqt/OTQtMath.h>
00080 #include <OpenTracker/otqt/OTQtLog.h>
00081 #include <OpenTracker/core/ConfigNode.h>
00082 #include <OpenTracker/core/Event.h>
00083
00084 #include <string>
00085
00086
00087
00135 namespace ot {
00136
00137 class OPENTRACKER_API ThreeToTwoDimCalc {
00138 public:
00145 typedef struct {
00147 Event local_cs_root;
00149 Event corner;
00150 } ASCorner;
00155 typedef struct {
00157 Event as_cs_root;
00159 ASCorner top_left;
00161 ASCorner top_right;
00163 ASCorner bottom_right;
00165 ASCorner bottom_left;
00166 } CalibInputData;
00171 class CalibOutputData
00172 {
00173 public:
00174 CalibOutputData()
00175 : as_cs_orient(4),
00176 as_cs_root_to_screen_root(3),
00177 as_width_vec(3),
00178 as_height_vec(3)
00179 {
00180
00181 };
00182 ~CalibOutputData()
00183 {};
00184 public:
00186 std::vector<float> as_cs_orient;
00188 std::vector<float> as_cs_root_to_screen_root;
00190 std::vector<float> as_width_vec;
00192 std::vector<float> as_height_vec;
00193 };
00194
00198 enum MPDLocationState {
00200 MPD_LOC_UNKNOWN = 0x00,
00202 MPD_LOC_INSIDE_SC = 0x01,
00204 MPD_LOC_OUTSIDE_SC = 0x02,
00205 };
00206
00207 private:
00213 class ASData
00214 {
00215 public:
00216 ASData()
00217 : as_cs_root(),
00218 as_screen_root(),
00219 as_width_vec(3),
00220 as_height_vec(3),
00221 as_depth_scalar_front(0),
00222 as_depth_scalar_back(0)
00223 {};
00224 ~ASData()
00225 {};
00226 public:
00228 Event as_cs_root;
00230 Event as_screen_root;
00232 std::vector<float> as_width_vec;
00234 std::vector<float> as_height_vec;
00236 float as_depth_scalar_front;
00238 float as_depth_scalar_back;
00239 };
00244 typedef struct {
00245 float x;
00246 float y;
00247 } Point;
00248
00249 typedef struct {
00251 Event position;
00253 bool mpd_loc_inside_screen_cuboid;
00255 Point desktop_coords;
00256 } MPData;
00257
00258 public:
00275 static void convert(CalibInputData const & in, CalibOutputData & out);
00283 static void convert(CalibOutputData const & out, StringTable & table);
00284
00285 public:
00294 ThreeToTwoDimCalc();
00295 ~ThreeToTwoDimCalc() { };
00296
00297 private:
00298
00299 public:
00309 void updateASPD(Event const & as_cs_root);
00320 void updateMPD(Event const & mpd_pos);
00326 MPDLocationState getMPDLocation() const;
00331 inline bool isMPDInsideScreenCuboid() const { return mp_data_.mpd_loc_inside_screen_cuboid; };
00337 inline Point getMPD2DCoords() const { return mp_data_.desktop_coords; };
00342 inline Event getMPD3DPosition() const { return mp_data_.position; };
00343
00348 void initCalibrationData(std::vector<float> aSWidthVec_, std::vector<float> aSHeightVec_,
00349 std::vector<float> cSOrientationQuat_, std::vector<float> cSRoot2ScreenRootVec_,
00350 float trackingSystemScaleOneMeter_, float screenDepthFrontInMeter_,
00351 float screenDepthBackInMeter_, float screenResWidth_, float screenResHeight_);
00352
00353
00354 private:
00356 CalibOutputData calib_out_;
00358 ASData as_data_init_;
00360 ASData as_data_;
00362 MPData mp_data_;
00363
00364 float screenResWidth, screenResHeight;
00365 };
00366
00367 }
00368
00369 #endif // USE_THREETOTWODIMFILTER
00370
00371 #endif // _THREETOTWODIMCALC_H
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388