32 #include <gp_cpp/gp_base.h>
33 #include <gp_cpp/gp_mean.h>
34 #include <gp_cpp/gp_covariance.h>
35 #include <gp_cpp/gp_prior.h>
36 #include <gp_cpp/gp_normal.h>
39 #include <boost/optional.hpp>
53 typedef gp::Prior<gp::Zero, gp::Squared_exponential> Gpp;
60 traj(vlen, height, width, girth),
61 btraj(vlen, height, width, girth),
62 ftraj(vlen, height, width, girth),
65 gp::Sqex(10.0, 100.0),
80 "Target dimensions must all be positive.");
117 return gp_fdir_prior;
162 const std::vector<Integral_flow>& x_flows,
163 const std::vector<Integral_flow>& y_flows,
164 const std::vector<Integral_flow>& back_x_flows,
165 const std::vector<Integral_flow>& back_y_flows,
180 bool infer_head =
true,
199 template<
class GetTraj,
class GetMean>
204 const std::vector<double>& nvar,
215 update_gp(gp_pos_prior, sc, sv);
221 update_gp(gp_dir_prior, sc, sv);
227 update_gp(gp_fdir_prior, sc, sv);
251 swap(t1.traj, t2.traj);
252 swap(t1.btraj, t2.btraj);
253 swap(t1.ftraj, t2.ftraj);
254 swap(t1.gp_pos_prior, t2.gp_pos_prior);
255 swap(t1.gp_dir_prior, t2.gp_dir_prior);
256 swap(t1.gp_fdir_prior, t2.gp_fdir_prior);
257 swap(t1.hessian_, t2.hessian_);
268 void update_gp(Gpp& gpp,
double sc,
double sv)
const;
274 boost::optional<double> get_position(
size_t fr,
size_t dim)
const
276 if(traj[fr - 1])
return traj[fr - 1]->value.position[dim];
280 boost::optional<double> get_bdir(
size_t fr)
const
282 if(traj[fr - 1])
return traj[fr - 1]->value.body_dir;
286 boost::optional<double> get_fdir(
size_t fr)
const
288 if(traj[fr - 1])
return traj[fr - 1]->value.face_dir[0];
292 double get_bdir_nc(
size_t fr)
const
294 return traj[fr - 1]->value.body_dir;
297 double get_zero(
size_t)
const
306 mutable Gpp gp_pos_prior;
307 mutable Gpp gp_dir_prior;
308 mutable Gpp gp_fdir_prior;
311 mutable Vector hessian_;
335 template<
class GetTraj,
class GetMean>
336 Vector Target::smooth_trajectory
340 const std::vector<double>& nvar,
347 typedef gp::Predictive<
348 gp::Real_function_adapter<size_t>,
350 gp::Linear_gaussian> Gppred;
353 "Cannot smooth trajectory; wrong number of variances.");
359 size_t nssz = nvar.size() + (sf - wsf) + (wef - ef);
360 Vector ns(static_cast<int>(nssz), 0.0);
361 assert(ns.size() >= nvar.size());
362 std::copy(nvar.begin(), nvar.end(), ns.begin() + sf - wsf);
365 gp::Inputs trins; trins.reserve(ns.size());
367 for(
size_t t = wsf; t <= wef; ++t)
369 boost::optional<double> dp = data(t);
373 trins.push_back(
Vector().set(t));
378 IFT(ns.size() == trins.size(), Illegal_argument,
379 "Cannot smooth trajectory; wrong number of variances.");
382 gp::Inputs teins = gp::make_inputs(sf, ef);
383 Gppred gp_pred = make_predictive(
384 gp::Real_function_adapter<size_t>(mean),
385 gp::Sqex(scale, svar),
387 trins, trouts, teins);
390 return gp_pred.normal().get_mean();
Generic_trajectory< Body_2d > Body_2d_trajectory
Definition: pt_body_2d_trajectory.h:36
Class that represents a detection bounding box from any source.
Definition: pt_detection_box.h:42
int get_end_time() const
Gets end time of track.
Definition: mcmcda_track.h:102
Definition of various standard probability distributions.
Vector get_cs_position(const Complete_state &cs)
Helper function – gets the position from CS as a kjb::Vector.
Definition: pt_target.h:316
Parent::const_iterator const_iterator
Definition: mcmcda_track.h:81
const Gpp & pos_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:103
void set_changed_start(int f) const
Set the changed flag of this track.
Definition: mcmcda_track.h:208
Target(double height, double width, double girth, size_t vlen)
Construct a target with the given height.
Definition: pt_target.h:59
Trajectory & trajectory() const
Get this target's current 3D positions.
Definition: pt_target.h:85
void update_pos_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:213
Int_matrix create_diagonal_matrix(const Int_matrix::Vec_type &diagonal)
Construct a one-row matrix by deep-copying a vector.
Definition: l_int_matrix.cpp:118
void refine_trajectory(const Perspective_camera &cam) const
Refine trajectory estimate using facemark information.
Definition: pt_target.cpp:328
void push_back(Value_type x)
inserts an element at the back of the vector in amortized constant time.
Definition: m_vector.h:1128
const Gpp & dir_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:109
height
Definition: APPgetLargeConnectedEdges.m:33
int get_start_time() const
Gets start time of track.
Definition: mcmcda_track.h:93
Face_2d_trajectory & face_trajectory() const
Get this target's current 2D body trajectory.
Definition: pt_target.h:97
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
A class that represents a generic MCMCDA track.
Definition: mcmcda_track.h:40
Value_type mean(Iterator begin, Iterator end, const Value_type &)
Definition: prob_stat.h:56
#define IFT(a, ex, msg)
Definition: l_exception.h:101
void update_fdir_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:225
Vector3 position
Definition: pt_complete_state.h:44
St_perspective_camera for modeling a perspective camera using the classic Forsyth and Ponce parametri...
Vector2 face_dir
Definition: pt_complete_state.h:46
Vector & hessian_diagonal() const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:237
void estimate_trajectory(const Perspective_camera &cam, double nsx=0.01, double nsz=1.0) const
Fix trajectory to match track.
Definition: pt_target.cpp:48
const Gpp & fdir_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:115
int changed_start() const
Returns changed start flag.
Definition: mcmcda_track.h:196
friend void swap(Target &t1, Target &t2)
Efficiently swap two targets.
Definition: pt_target.h:247
void set_unchanged() const
Set changed flags to unchanged.
Definition: pt_target.h:122
Definition: perspective_camera.h:93
Vector & set(Value_type val)
Clone of zero_out(int)
Definition: m_vector.h:707
void reserve(int capacity)
Definition: m_vector.h:618
Class that represents a target moving through space.
Definition: pt_target.h:50
Body_2d_trajectory & body_trajectory() const
Get this target's current 2D body trajectory.
Definition: pt_target.h:91
void sync_state(const Target &tg)
Sync targets trajectory with endpoints.
Definition: pt_target.cpp:624
Generic_trajectory< Complete_state > Trajectory
Definition: pt_complete_trajectory.h:42
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
Detection_box Element
Definition: pt_target.h:56
void set_changed_end(int f) const
Set the changed flag of this track.
Definition: mcmcda_track.h:214
#define M_PI
Definition: fft.cpp:206
Int_matrix::Value_type min(const Int_matrix &mat)
Return the minimum value in this matrix.
Definition: l_int_matrix.h:1385
void update_boxes(const Perspective_camera &cam) const
Update box trajectory.
Definition: pt_target.cpp:503
void set_changed_all() const
Set changed flags to unchanged.
Definition: pt_target.h:129
Vector get_cs_face_dir(const Complete_state &cs)
Helper function – gets the face_dir from CS as a kjb::Vector.
Definition: pt_target.h:323
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
void estimate_height(const Perspective_camera &cam) const
Estimate height from boxes and camera.
Definition: pt_target.cpp:287
void update_faces(const Perspective_camera &cam) const
Update face trajectory.
Definition: pt_target.cpp:551
Generic_trajectory< Face_2d > Face_2d_trajectory
Definition: pt_face_2d_trajectory.h:36
void scale(kjb::Axis_aligned_rectangle_2d &box, const kjb::Vector &s)
Definition: gr_2D_bounding_box.cpp:108
bool changed() const
Return true if this target has changed.
Definition: pt_target.h:136
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
Represents the state of an actor at a frame.
Definition: pt_complete_state.h:42
void estimate_directions(bool infer_head=true, double nsb=0.1, double nsf=0.1) const
Estimate directions.
Definition: pt_target.cpp:406
void update_dir_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:219
int changed_end() const
Returns changed end flag.
Definition: mcmcda_track.h:202