ThreeToTwoDimCalc.h

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (c) 2006,
00003  * Institute for Computer Graphics and Vision
00004  * Graz University of Technology
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are
00009  * met:
00010  *
00011  * Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the following disclaimer.
00013  *
00014  * Redistributions in binary form must reproduce the above copyright
00015  * notice, this list of conditions and the following disclaimer in the
00016  * documentation and/or other materials provided with the distribution.
00017  *
00018  * Neither the name of the Graz University of Technology nor the names of
00019  * its contributors may be used to endorse or promote products derived from
00020  * this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00023  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00024  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00025  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00026  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  * ========================================================================
00034  * PROJECT: OpenTracker
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 //#include <QtCore/qpoint.h>
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           //OTQT_DEBUG("CalibOutputData(): as_cs_orient.size () = %i\n", as_cs_orient.size());
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: // methods
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: // members
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 } // namespace ot
00368 
00369 #endif // USE_THREETOTWODIMFILTER
00370 
00371 #endif // _THREETOTWODIMCALC_H
00372 
00373 
00374 /*
00375  * ------------------------------------------------------------
00376  *   End of ThreeToTwoDimCalc.h
00377  * ------------------------------------------------------------
00378  *   Automatic Emacs configuration follows.
00379  *   Local Variables:
00380  *   mode:c++
00381  *   c-basic-offset: 4
00382  *   eval: (c-set-offset 'substatement-open 0)
00383  *   eval: (c-set-offset 'case-label '+)
00384  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00385  *   eval: (setq indent-tabs-mode nil)
00386  *   End:
00387  * ------------------------------------------------------------
00388  */

Generated on Wed Feb 28 15:18:48 2007 for NaviTrack by  doxygen 1.4.6