back_projection.h

00001 /***************************************************************************
00002  *  back_projection.h - Projective camera back projection model
00003  *
00004  *  Created:  Mon Apr 20 21:59:00 2009
00005  *  Copyright 2009 Christof Rath <christof.rath@gmail.com>
00006  *
00007  ****************************************************************************/
00008
00009 /*  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  Read the full text in the LICENSE.GPL file in the doc directory.
00020  */
00021
00022 #ifndef BACK_PROJECTION_H_
00023 #define BACK_PROJECTION_H_
00024 
00025 #include "relativepositionmodel.h"
00026
00027 #include <models/camera/projective_cam.h>
00028 #include <utils/math/types.h>
00029
00030 class BackProjectionPositionModel :
00031   public RelativePositionModel
00032 {
00033 public:
00034   BackProjectionPositionModel(ProjectiveCam &projective_cam,
00035                               float ball_circumference = 0.f);
00036
00037   virtual const char *  get_name() const { return "BackProjectionPositionModel"; }
00038   virtual void          set_radius(float r);
00039   virtual void          set_center(float x, float y);
00040   virtual void          set_center(const center_in_roi_t& c) { set_center(c.x, c.y); }
00041
00042   virtual void          set_pan_tilt(float pan = 0.0f, float tilt = 0.0f) { set_cam_rotation(pan, tilt, 0.f); }
00043   virtual void          get_pan_tilt(float *pan, float *tilt) const;
00044
00045   virtual void          set_cam_rotation(float pan = 0.f, float tilt = 0.f, float roll = 0.f);
00046   virtual void          get_cam_rotation(float &pan, float &tilt, float &roll) const;
00047
00048   virtual void          set_cam_translation(float height, float rel_x = 0.f, float rel_y = 0.f);
00049   virtual void          get_cam_translation(float &height, float &rel_x, float &rel_y) const;
00050
00051   virtual float         get_distance() const { return __distance; }
00052   virtual float         get_x() const        { return __world_x; }
00053   virtual float         get_y() const        { return __world_y; }
00054   virtual float         get_bearing() const  { return __bearing; }
00055   virtual float         get_slope() const    { return __slope; }
00056
00057   virtual void          calc();
00058   virtual void          calc_unfiltered()    { calc(); }
00059   virtual void          reset();
00060
00061   virtual bool          is_pos_valid() const { return __pos_valid; }
00062
00063 private:
00064   ProjectiveCam&  __projective_cam;
00065
00066   center_in_roi_t       __cirt_center;
00067
00068   fawkes::point_6D_t    __cam_position;
00069
00070   float                 __ball_circumference;
00071   float                 __ball_radius;
00072   float                 __world_x;
00073   float                 __world_y;
00074   float                 __bearing;
00075   float                 __slope;
00076   float                 __distance;
00077   bool                  __pos_valid;
00078 };
00079
00080 #endif /* BACK_PROJECTION_H_ */