KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_direction_prior.h
Go to the documentation of this file.
1 /* =========================================================================== *
2 |
3 | Copyright (c) 1994-2008 by Kobus Barnard (author).
4 |
5 | Personal and educational use of this code is granted, provided that this
6 | header is kept intact, and that the authorship is not misrepresented, that
7 | its use is acknowledged in publications, and relevant papers are cited.
8 |
9 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10 |
11 | Please note that the code in this file has not necessarily been adequately
12 | tested. Naturally, there is no guarantee of performance, support, or fitness
13 | for any particular task. Nonetheless, I am interested in hearing about
14 | problems that you encounter.
15 |
16 * =========================================================================== */
17 
18 /* $Id: pt_direction_prior.h 18657 2015-03-18 14:43:48Z ernesto $ */
19 
20 #ifndef PT_DIRECTION_PRIOR_H_
21 #define PT_DIRECTION_PRIOR_H_
22 
25 #include <gp_cpp/gp_prior.h>
26 
27 namespace kjb {
28 namespace pt {
29 
34 {
35 private:
36  typedef gp::Prior<gp::Zero, gp::Squared_exponential> Gpp;
37 
38 public:
40  Direction_prior(double sc, double sv, size_t local_sz) :
41  gpsc_(sc),
42  gpsv_(sv),
43  local_dist_(
44  gp::Zero(),
45  gp::Sqex(1.0, 1.0),
46  gp::Inputs::const_iterator(),
47  gp::Inputs::const_iterator()),
48  m_local_sz(local_sz)
49  {
50  if(m_local_sz % 2 == 0)
51  {
52  m_local_sz++;
53  }
54 
55  if(m_local_sz <= 1)
56  {
57  m_local_sz = 3;
58  }
59  }
60 
62  Direction_prior(double sc, double sv) :
63  gpsc_(sc),
64  gpsv_(sv),
65  local_dist_(
66  gp::Zero(),
67  gp::Sqex(1.0, 1.0),
68  gp::Inputs::const_iterator(),
69  gp::Inputs::const_iterator()),
70  m_local_sz(8*gpsc_)
71  {
72  if(m_local_sz % 2 == 0)
73  {
74  m_local_sz++;
75  }
76 
77  if(m_local_sz <= 1)
78  {
79  m_local_sz = 3;
80  }
81  }
82 
84  double operator()(const Scene& scene) const;
85 
87  double at_trajectory(const Target& target) const;
88 
90  double local(const Target& target, size_t t) const;
91 
93  size_t local_size() const { return m_local_sz; }
94 
96  double scale() const { return gpsc_; }
97 
99  double signal_variance() const { return gpsv_; }
100 
101 private:
103  double get_mean(const Target& target, size_t t) const
104  {
105  int sf = target.get_start_time();
106  int ef = target.get_end_time();
107  assert(sf != -1 && ef != -1);
108  assert(t >= sf && t <= ef);
109 
110 // double mn = 0.0;
111 // if(t == ef)
112 // {
113 // if(t != sf)
114 // {
115 // mn = get_initial_direction(target.trajectory(), t - 1);
116 // }
117 // }
118 // else
119 // {
120 // mn = get_initial_direction(target.trajectory(), t);
121 // }
122 
123  double mn = target.trajectory()[t - 1]->value.body_dir;
124 
125  return mn;
126  }
127 
128  double gpsc_;
129  double gpsv_;
130  mutable Gpp local_dist_;
131  size_t m_local_sz;
132 };
133 
138 {
139 private:
140  typedef gp::Prior<gp::Zero, gp::Squared_exponential> Gpp;
141 
142 public:
144  Face_direction_prior(double sc, double sv, size_t local_sz) :
145  gpsc_(sc),
146  gpsv_(sv),
147  local_dist_(
148  gp::Zero(),
149  gp::Sqex(1.0, 1.0),
150  gp::Inputs::const_iterator(),
151  gp::Inputs::const_iterator()),
152  m_local_sz(local_sz)
153  {
154  if(m_local_sz % 2 == 0)
155  {
156  m_local_sz++;
157  }
158 
159  if(m_local_sz <= 1)
160  {
161  m_local_sz = 3;
162  }
163  }
164 
166  Face_direction_prior(double sc, double sv) :
167  gpsc_(sc),
168  gpsv_(sv),
169  local_dist_(
170  gp::Zero(),
171  gp::Sqex(1.0, 1.0),
172  gp::Inputs::const_iterator(),
173  gp::Inputs::const_iterator()),
174  m_local_sz(8*gpsc_)
175  {
176  if(m_local_sz % 2 == 0)
177  {
178  m_local_sz++;
179  }
180 
181  if(m_local_sz <= 1)
182  {
183  m_local_sz = 3;
184  }
185  }
186 
188  double operator()(const Scene& scene) const;
189 
191  double at_trajectory(const Target& target) const;
192 
194  double local(const Target& target, size_t t) const;
195 
197  size_t local_size() const { return m_local_sz; }
198 
200  double scale() const { return gpsc_; }
201 
203  double signal_variance() const { return gpsv_; }
204 
205 private:
207  double get_mean(const Target& target, size_t t) const
208  {
209  return target.trajectory()[t - 1]->value.body_dir;
210  }
211 
212  double gpsc_;
213  double gpsv_;
214  mutable Gpp local_dist_;
215  size_t m_local_sz;
216 };
217 
218 }} //namespace kjb::pt
219 
220 #endif /*PT_DIRECTION_PRIOR_H_ */
221 
Class that represents the prior distribution of a trajectory.
Definition: pt_direction_prior.h:33
int get_end_time() const
Gets end time of track.
Definition: mcmcda_track.h:102
Trajectory & trajectory() const
Get this target's current 3D positions.
Definition: pt_target.h:85
Class that represents the prior distribution of the face direction.
Definition: pt_direction_prior.h:137
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
size_t local_size() const
Return the local window size.
Definition: pt_direction_prior.h:197
int get_start_time() const
Gets start time of track.
Definition: mcmcda_track.h:93
double at_trajectory(const Target &target) const
Evaluate this prior on the given trajectory.
Definition: pt_direction_prior.cpp:56
Direction_prior(double sc, double sv, size_t local_sz)
Construct a prior.
Definition: pt_direction_prior.h:40
Face_direction_prior(double sc, double sv)
Construct a prior.
Definition: pt_direction_prior.h:166
double local(const Target &target, size_t t) const
Approximate this prior around a frame.
Definition: pt_direction_prior.cpp:169
double operator()(const Scene &scene) const
Evaluate this prior on the given scene.
Definition: pt_direction_prior.cpp:130
double signal_variance() const
Return the GP signal variance.
Definition: pt_direction_prior.h:99
double scale() const
Return the GP scale.
Definition: pt_direction_prior.h:96
Class that represents a target moving through space.
Definition: pt_target.h:50
Direction_prior(double sc, double sv)
Construct a prior.
Definition: pt_direction_prior.h:62
double local(const Target &target, size_t t) const
Approximate this prior around a frame.
Definition: pt_direction_prior.cpp:77
double scale() const
Return the GP scale.
Definition: pt_direction_prior.h:200
Face_direction_prior(double sc, double sv, size_t local_sz)
Construct a prior.
Definition: pt_direction_prior.h:144
size_t local_size() const
Return the local window size.
Definition: pt_direction_prior.h:93
double operator()(const Scene &scene) const
Evaluate this prior on the given scene.
Definition: pt_direction_prior.cpp:43
double at_trajectory(const Target &target) const
Evaluate this prior on the given trajectory.
Definition: pt_direction_prior.cpp:143
double signal_variance() const
Return the GP signal variance.
Definition: pt_direction_prior.h:203