KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_scene_generative_model.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 | Authors:
17 | Ernesto Brau
18 |
19 * =========================================================================== */
20 
21 /* $Id$ */
22 
23 #ifndef PT_SCENE_GENERATIVE_MOODEL_H
24 #define PT_SCENE_GENERATIVE_MOODEL_H
25 
39 #include <m_cpp/m_vector.h>
41 #include <prob_cpp/prob_sample.h>
42 #include <gp_cpp/gp_sample.h>
43 #include <detector_cpp/d_bbox.h>
45 #include <vector>
46 #include <algorithm>
47 #include <functional>
48 #include <utility>
49 #include <boost/bind.hpp>
50 #include <boost/ref.hpp>
51 
52 namespace kjb {
53 namespace pt {
54 
56 inline
57 bool pixel_visible(int x, int y, const Visibility& vis)
58 {
59  if(fabs(vis.visible - 0.0) < 1e-6) return false;
60  if(fabs(vis.visible - 1.0) < 1e-6) return true;
61 
62  for(size_t i = 0; i < vis.visible_cells.size(); i++)
63  {
64  Bbox cell(vis.visible_cells[i], vis.cell_width, vis.cell_height);
65  if(cell.contains(Vector().set(x, y))) return true;
66  }
67 
68  return false;
69 }
70 
72 inline bool empty_target(const Target& target) { return target.size() < 2; }
73 
75 inline
76 void fix_target(Target& target, double imw, double imh)
77 {
78  const Trajectory& traj = target.trajectory();
79  const Body_2d_trajectory& btraj = target.body_trajectory();
80  Bbox imbox(Vector(0.0, 0.0), imw, imh);
81  for(Target::iterator pr_p = target.begin(); pr_p != target.end(); pr_p++)
82  {
83  size_t t = pr_p->first;
84 
85  const Vector3& pos = traj[t - 1]->value.position;
86  const Bbox& fbox = btraj[t - 1]->value.full_bbox;
87  if(pos[2] >= -1.0
88  || get_rectangle_intersection(imbox, fbox) < 0.5*fbox.get_area())
89  {
90  // kill track from here on
91  target.erase(pr_p, target.end());
92  if(!empty_target(target))
93  {
94  sync_state(target);
95  }
96  return;
97  }
98  }
99 }
100 
107 template<class TargetIterator>
108 void sample
109 (
110  const Position_prior& pos_prior,
111  const Direction_prior& dir_prior,
112  const Face_direction_prior& fdir_prior,
113  const Normal_distribution& height_prior,
114  const Normal_distribution& width_prior,
115  const Normal_distribution& girth_prior,
116  TargetIterator first,
117  TargetIterator last
118 )
119 {
120  for(TargetIterator target_p = first; target_p != last; target_p++)
121  {
122  Target& target = *target_p;
123  Trajectory& traj = target.trajectory();
124  int sf = target.get_start_time();
125  int ef = target.get_end_time();
126 
127  // set trajectory
128  target.update_pos_gp(pos_prior.scale(), pos_prior.signal_variance());
129  std::vector<Vector> F_x(2);
130 
131  F_x[0] = kjb::gp::sample(target.pos_prior());
132  F_x[1] = kjb::gp::sample(target.pos_prior());
133  for(size_t f = sf; f <= ef; f++)
134  {
135  traj[f - 1] = Trajectory_element();
136  traj[f - 1]->value.position[0] = F_x[0][f - sf];
137  traj[f - 1]->value.position[2] = F_x[1][f - sf] - 5.0;;
138  }
139 
140  // set body direction
141  target.update_dir_gp(dir_prior.scale(), dir_prior.signal_variance());
142  Vector F_d = kjb::gp::sample(target.dir_prior());
143  for(size_t f = sf; f <= ef; f++)
144  {
145  traj[f - 1]->value.body_dir = F_d[f - sf];
146  }
147 
148  // set face directions
149  target.update_fdir_gp(fdir_prior.scale(), fdir_prior.signal_variance());
150  Vector F_p = kjb::gp::sample(target.fdir_prior());
151  Vector F_y = kjb::gp::sample(target.fdir_prior());
152  for(size_t f = sf; f <= ef; f++)
153  {
154  traj[f - 1]->value.face_dir[0] = F_p[f - sf];
155  traj[f - 1]->value.face_dir[1] = F_y[f - sf];
156  }
157 
158  // set height, width and girth
159  traj.height = kjb::sample(height_prior);
160  traj.width = kjb::sample(width_prior);
161  traj.girth = kjb::sample(girth_prior);
162  }
163 }
164 
166 inline
168 {
169  Perspective_camera cam(0.1, 10000);
170  cam.set_camera_centre_y(kjb::sample(cam_prior.height_prior()));
171  cam.set_pitch(kjb::sample(cam_prior.pitch_prior()));
173 
174  return cam;
175 }
176 
183 inline
184 Detection_box sample
185 (
186  const Box_likelihood& box_lh,
187  const Bbox& mbox,
188  const std::string& type
189 )
190 {
191  Vector params_x(4, 0.0);
192  Vector params_top(4, 0.0);
193  Vector params_bot(4, 0.0);
194  box_lh.get_params(type, params_x, params_top, params_bot);
195 
196  double height = mbox.get_top() - mbox.get_bottom();
197  if(height <= 0.0)
198  {
199  std::cerr << "WARNING: person behind camera!" << std::endl;
200  height = -height;
201  }
202 
203  double mean = params_x[0] + params_x[2] * height;
204  double b = params_x[1] + params_x[3] * height;
205  Laplace_distribution P_x(mean, b);
206 
207  mean = params_top[0] + params_top[2] * height;
208  b = params_top[1] + params_top[3] * height;
209  Laplace_distribution P_top(mean, b);
210 
211  mean = params_bot[0] + params_bot[2] * height;
212  b = params_bot[1] + params_bot[3] * height;
213  Laplace_distribution P_bot(mean, b);
214 
215  double dx = kjb::sample(P_x);
216  double dtop = kjb::sample(P_top);
217  double dbot = kjb::sample(P_bot);
218 
219  Vector c = mbox.get_center();
220  c[0] += dx;
221  double top = mbox.get_top() + dtop;
222  double bot = mbox.get_bottom() + dbot;
223 
224  return Detection_box(Bbox(c, mbox.get_width(), top - bot), 0.0, type);
225 }
226 
233 template<class TargetIterator>
234 void sample
235 (
236  const Box_likelihood& box_lh,
237  Box_data& box_data,
238  TargetIterator first,
239  TargetIterator last,
240  const std::vector<size_t> fa_count
241 )
242 {
243  const size_t T = fa_count.size();
244 
245  box_data.clear();
246  box_data.resize(T);
247 
248  // true detections
249  for(TargetIterator target_p = first; target_p != last; target_p++)
250  {
251  Target& target = *target_p;
252  Body_2d_trajectory& btraj = target.body_trajectory();
253 
254  BOOST_FOREACH(Target::value_type& pr, target)
255  {
256  const Target::key_type& t = pr.first;
257  Target::mapped_type& b_p = pr.second;
258 
259  const Body_2d& b2d = btraj[t - 1]->value;
260  const Bbox& fbox = b2d.full_bbox;
261 
262  Detection_box dbox = sample(box_lh, fbox, "deva_box");
263  b_p = &(*box_data[t - 1].insert(dbox).first);
264  }
265  }
266 
267  // false alarms
268  double imw = box_data.image_width();
269  double imh = box_data.image_height();
270  for(size_t t = 0; t < T; t++)
271  {
272  for(size_t i = 0; i < fa_count[t]; i++)
273  {
274  Uniform_distribution U_h(-imh/2, imh/2);
275  Uniform_distribution U_w(-imw/2, imw/2);
276 
277  double top = kjb::sample(U_h);
278  double bot = kjb::sample(U_h);
279  double xc = kjb::sample(U_w);
280  double yc = (top - bot)/2;
281 
282  double h = fabs(top - bot);
283  double w = h/3;
284  Vector c(xc, yc);
285  box_data[t].insert(Detection_box(Bbox(c, w, h), 0.8, "noise"));
286  }
287  }
288 }
289 
293 template<class FmvIterator>
294 void sample
295 (
296  const Facemark_likelihood& fm_lh,
297  const Scene& scene,
298  FmvIterator fm_out
299 )
300 {
301  const Ascn& w = scene.association;
302  for(size_t t = 0; t < w.get_data().size(); t++)
303  {
304  std::vector<Deva_facemark> facemarks_t;
305  BOOST_FOREACH(const Target& tg, w)
306  {
307  const Face_2d_trajectory ftraj = tg.face_trajectory();
308  if(ftraj[t])
309  {
310  const Face_2d& f2d = ftraj[t]->value;
311  double fd = tg.trajectory()[t]->value.face_dir[0];
312  fd += tg.trajectory()[t]->value.body_dir;
313  while(fd > M_PI) fd -= M_PI;
314  while(fd < -M_PI) fd += M_PI;
315  double yaw = (180*fd)/M_PI;
316  if(f2d.visibility.visible >= 0.5)
317  {
318  if(kjb::sample(Uniform_distribution()) <= 0.5)
319  {
320  Vector le_mark;
321  Vector re_mark;
322  Vector n_mark;
323  Vector lm_mark;
324  Vector rm_mark;
325 
326  const Normal_distribution& N_ex = fm_lh.eye_x_dist();
327  const Normal_distribution& N_ey = fm_lh.eye_y_dist();
328  const Normal_distribution& N_nx = fm_lh.nose_x_dist();
329  const Normal_distribution& N_ny = fm_lh.nose_y_dist();
330  const Normal_distribution& N_mx = fm_lh.mouth_x_dist();
331  const Normal_distribution& N_my = fm_lh.mouth_y_dist();
332 
333  bool all_empty = true;
334  if(!f2d.left_eye.empty())
335  {
336  le_mark.set(f2d.left_eye[0] + kjb::sample(N_ex),
337  f2d.left_eye[1] + kjb::sample(N_ey));
338  all_empty = false;
339  }
340 
341  if(!f2d.right_eye.empty())
342  {
343  re_mark.set(f2d.right_eye[0] + kjb::sample(N_ex),
344  f2d.right_eye[1] + kjb::sample(N_ey));
345  all_empty = false;
346  }
347 
348  if(!f2d.nose.empty())
349  {
350  n_mark.set(f2d.nose[0] + kjb::sample(N_nx),
351  f2d.nose[1] + kjb::sample(N_ny));
352  all_empty = false;
353  }
354 
355  if(!f2d.left_mouth.empty())
356  {
357  lm_mark.set(f2d.left_mouth[0] + kjb::sample(N_mx),
358  f2d.left_mouth[1] + kjb::sample(N_my));
359  all_empty = false;
360  }
361 
362  if(!f2d.right_mouth.empty())
363  {
364  rm_mark.set(f2d.right_mouth[0] + kjb::sample(N_mx),
365  f2d.right_mouth[1] + kjb::sample(N_my));
366  all_empty = false;
367  }
368 
369  if(!all_empty)
370  {
371  facemarks_t.push_back(build_deva_facemark(le_mark,
372  re_mark,
373  n_mark,
374  lm_mark,
375  rm_mark,
376  yaw));
377  }
378  }
379  }
380  }
381  }
382 
383  *fm_out++ = facemarks_t;
384  }
385 }
386 
393 template<class FlowIterator>
394 void sample
395 (
396  const Optical_flow_likelihood& of_lh,
397  const Scene& scene,
398  FlowIterator xflow_out,
399  FlowIterator yflow_out
400 )
401 {
402  const Ascn& w = scene.association;
403  const Box_data& data = static_cast<const Box_data&>(w.get_data());
404  const size_t T = data.size();
405  const double image_width = data.image_width();
406  const double image_height = data.image_height();
407 
408  // BG flow
409  const Laplace_distribution& L_bg_x = of_lh.bg_x_dist();
410  const Laplace_distribution& L_bg_y = of_lh.bg_y_dist();
411 
412  Matrix bg_flow_x((size_t)image_height, (size_t)image_width);
413  Matrix bg_flow_y((size_t)image_height, (size_t)image_width);
414  for(size_t i = 0; i < (size_t)image_width; i++)
415  {
416  for(size_t j = 0; j < image_height; j++)
417  {
418  bg_flow_x(j, i) = kjb::sample(L_bg_x);
419  bg_flow_y(j, i) = kjb::sample(L_bg_y);
420  }
421  }
422 
423  // FG flow
424  const Laplace_distribution& L_x = of_lh.x_dist();
425  const Laplace_distribution& L_y = of_lh.y_dist();
426  for(size_t f = 0; f < T - 1; f++)
427  {
428  Matrix flow_x = bg_flow_x;
429  Matrix flow_y = bg_flow_y;
430  BOOST_FOREACH(const Target& target, w)
431  {
432  const Body_2d_trajectory& btraj = target.body_trajectory();
433  const Face_2d_trajectory& ftraj = target.face_trajectory();
434 
435  if(!btraj[f] || !btraj[f + 1]) continue;
436 
437  // get body model vector
438  const Bbox& curbox = btraj[f]->value.body_bbox;
439  const Bbox& nxtbox = btraj[f + 1]->value.body_bbox;
440  const Visibility& vis = btraj[f]->value.visibility;
441  Vector model_vel = nxtbox.get_center() - curbox.get_center();
442  model_vel[0] += kjb::sample(L_x);
443  model_vel[1] += kjb::sample(L_y);
444 
445  int bl = std::max(curbox.get_left(), -image_width/2.0);
446  int br = std::min(curbox.get_right(), image_width/2.0 - 1);
447  int bb = std::max(curbox.get_bottom(), -image_height/2.0 + 1);
448  int bt = std::min(curbox.get_top(), image_height/2.0);
449 
450  // for every pixel, set flow
451  for(int x = bl; x <= br; x++)
452  {
453  for(int y = bb; y <= bt; y++)
454  {
455  if(pixel_visible(x, y, vis))
456  {
457  Vector vs = Vector().set(x, y);
458  Vector vd = vs + model_vel;
459  unstandardize(vs, image_width, image_height);
460  unstandardize(vd, image_width, image_height);
461  flow_x(vs[1], vs[0]) = (vd - vs)[0];
462  flow_y(vs[1], vs[0]) = (vd - vs)[1];
463  }
464  }
465  }
466 
467  // get face model vector
468  const Bbox& facebox = ftraj[f]->value.bbox;
469  const Visibility& facevis = ftraj[f]->value.visibility;
470  model_vel = ftraj[f]->value.model_dir;
471  model_vel[0] += kjb::sample(L_x);
472  model_vel[1] += kjb::sample(L_y);
473 
474  bl = std::max(facebox.get_left(), -image_width/2.0);
475  br = std::min(facebox.get_right(), image_width/2.0 - 1);
476  bb = std::max(facebox.get_bottom(), -image_height/2.0 + 1);
477  bt = std::min(facebox.get_top(), image_height/2.0);
478 
479  // for every pixel, set flow
480  for(int x = bl; x <= br; x++)
481  {
482  for(int y = bb; y <= bt; y++)
483  {
484  if(pixel_visible(x, y, facevis))
485  {
486  Vector vs = Vector().set(x, y);
487  Vector vd = vs + model_vel;
488  unstandardize(vs, image_width, image_height);
489  unstandardize(vd, image_width, image_height);
490  flow_x(vs[1], vs[0]) = (vd - vs)[0];
491  flow_y(vs[1], vs[0]) = (vd - vs)[1];
492  }
493  }
494  }
495  }
496 
497  // generate integral flow
498  *xflow_out++ = Integral_flow(flow_x, 4);
499  *yflow_out++ = Integral_flow(flow_y, 4);
500  }
501 }
502 
509 template<class FmvIterator, class FlowOutIterator>
510 void sample
511 (
512  const mcmcda::Prior<Target>& w_prior,
513  const Camera_prior& cam_prior,
514  const Scene_posterior& posterior,
515  size_t T,
516  Scene& scene,
517  Box_data& box_data,
518  FmvIterator fm_out,
519  FlowOutIterator xflow_out,
520  FlowOutIterator yflow_out,
521  size_t max_tracks = 0
522 )
523 {
524  using namespace std;
525 
526  Perspective_camera& cam = scene.camera;
527  Ascn& w = scene.association;
528  scene.kappa = w_prior.kappa();
529  scene.theta = w_prior.theta();
530  scene.lambda = w_prior.lambda_N();
531 
532  // distributions
533  const Position_prior& pos_prior = posterior.position_prior();
534  const Direction_prior& dir_prior = posterior.direction_prior();
535  const Face_direction_prior& fdir_prior = posterior.face_direction_prior();
536  const Normal_distribution& height_prior = posterior.height_prior();
537  const Normal_distribution& width_prior = posterior.width_prior();
538  const Normal_distribution& girth_prior = posterior.girth_prior();
539  const Box_likelihood& box_lh = posterior.box_likelihood();
540  const Facemark_likelihood& fm_lh = posterior.fm_likelihood();
541  const Optical_flow_likelihood& of_lh = posterior.of_likelihood();
542 
543  // sample tracks
544  pair<vector<Target>, vector<size_t> >
545  wfa = mcmcda::sample(w_prior, T, Target(1.8, 0.3, 0.3, T));
546  vector<Target>& targets = wfa.first;
547  const vector<size_t>& false_alarms = wfa.second;
548 
549  // sample camera
550  cam = sample(cam_prior);
551 
552  // sample 3D scene
553  sample(
554  pos_prior,
555  dir_prior,
556  fdir_prior,
557  height_prior,
558  width_prior,
559  girth_prior,
560  targets.begin(),
561  targets.end());
562 
563  // fix targets (they cannot go off-image)
564  typedef std::vector<Target>::iterator Tv_it;
565  double imw = box_data.image_width();
566  double imh = box_data.image_height();
567  std::for_each(
568  targets.begin(),
569  targets.end(),
570  boost::bind(&Target::set_changed_all, _1));
571  std::for_each(
572  targets.begin(),
573  targets.end(),
574  boost::bind(&Target::update_boxes, _1, boost::cref(cam)));
575  std::for_each(
576  targets.begin(),
577  targets.end(),
578  boost::bind(fix_target, _1, imw, imh));
579 
580  Tv_it ltg_p = std::remove_if(targets.begin(), targets.end(), empty_target);
581  if(max_tracks != 0 && std::distance(targets.begin(), ltg_p) > max_tracks)
582  {
583  ltg_p = targets.begin();
584  std::advance(ltg_p, max_tracks);
585  }
586 
587  // update state
588  std::for_each(
589  targets.begin(),
590  ltg_p,
591  boost::bind(&Target::set_changed_all, _1));
592  std::for_each(
593  targets.begin(),
594  ltg_p,
595  boost::bind(&Target::update_boxes, _1, boost::cref(cam)));
596  std::for_each(
597  targets.begin(),
598  ltg_p,
599  boost::bind(&Target::update_faces, _1, boost::cref(cam)));
600 
601  // sample box data
602  sample(box_lh, box_data, targets.begin(), ltg_p, false_alarms);
603 
604  // update association
605  w.set_data(box_data);
606  w.insert(targets.begin(), ltg_p);
607  update_visibilities(scene);
608 
609  // sample FM data
610  sample(fm_lh, scene, fm_out);
611 
612  // sample OF data
613  sample(of_lh, scene, xflow_out, yflow_out);
614 }
615 
616 }} // namespace kjb::pt
617 
618 #endif /*PT_SCENE_GENERATIVE_MOODEL_H */
619 
Class that represents the prior distribution of a trajectory.
Definition: pt_direction_prior.h:33
double get_width() const
returns the width of this bounding box
Definition: gr_2D_bounding_box.h:86
Vector right_eye
Definition: pt_face_2d.h:41
const Laplace_distribution & bg_y_dist() const
Return the individual Laplace distribution for y.
Definition: pt_optical_flow_likelihood.h:87
Vector left_mouth
Definition: pt_face_2d.h:43
Class that represents a detection bounding box from any source.
Definition: pt_detection_box.h:42
const Face_direction_prior & face_direction_prior() const
Returns the face direction prior.
Definition: pt_scene_posterior.h:169
const Normal_distribution & eye_y_dist() const
Definition: pt_facemark_likelihood.h:113
int get_end_time() const
Gets end time of track.
Definition: mcmcda_track.h:102
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center...
Definition: gr_2D_bounding_box.h:51
double height
Definition: tracking_trajectory.h:195
bool empty() const
Returns true iff size is zero. Required to comply with stl Container concept.
Definition: m_vector.h:526
Deva_facemark build_deva_facemark(const Vector &lefe_eye, const Vector &right_eye, const Vector &nose, const Vector &left_mouth, const Vector &right_mouth, double yaw)
Constructor.
Definition: pt_data.cpp:167
Definition of various standard probability distributions.
Parent::key_type key_type
Definition: mcmcda_track.h:85
bool contains(const kjb::Vector &pt) const
Definition: gr_2D_bounding_box.h:138
double image_width() const
Returns the image width.
Definition: pt_data.h:86
const Normal_distribution & mouth_y_dist() const
Definition: pt_facemark_likelihood.h:117
Definition: pt_data.h:41
double signal_variance() const
Return the GP signal variance.
Definition: pt_position_prior.h:108
const Gpp & pos_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:103
Trajectory & trajectory() const
Get this target's current 3D positions.
Definition: pt_target.h:85
double get_bottom() const
Definition: gr_2D_bounding_box.h:99
double get_area() const
returns the area of the box
Definition: gr_2D_bounding_box.h:211
double lambda
Definition: pt_scene.h:63
const Laplace_distribution & x_dist() const
Return the individual Laplace distribution for x.
Definition: pt_optical_flow_likelihood.h:78
Class to compute face optical flow likelihood.
Definition: pt_optical_flow_likelihood.h:43
const Optical_flow_likelihood & of_likelihood() const
Returns the optical flow likelihood.
Definition: pt_scene_posterior.h:190
Class that represents the prior distribution of the face direction.
Definition: pt_direction_prior.h:137
void update_pos_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:213
Parent::mapped_type mapped_type
Definition: mcmcda_track.h:86
double get_right() const
Definition: gr_2D_bounding_box.h:98
Vector nose
Definition: pt_face_2d.h:42
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
Generic_trajectory_element< Complete_state > Trajectory_element
Definition: pt_complete_trajectory.h:41
virtual void set_focal_length(double ifocal)
sets the focal length
Definition: perspective_camera.cpp:872
const Facemark_likelihood & fm_likelihood() const
Returns the facemark likelihood.
Definition: pt_scene_posterior.h:187
Ascn association
Definition: pt_scene.h:59
void push_back(Value_type x)
inserts an element at the back of the vector in amortized constant time.
Definition: m_vector.h:1128
2D body information resulting from projecting the 3D body.
Definition: pt_body_2d.h:35
Vector left_eye
Definition: pt_face_2d.h:40
bool empty_target(const Target &target)
Helper function; needed because, occasionally, C++ is stupid.
Definition: pt_scene_generative_model.h:72
const Gpp & dir_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:109
height
Definition: APPgetLargeConnectedEdges.m:33
Computes the prior of an MCMCDA association.
Definition: mcmcda_prior.h:38
double image_height() const
Returns the image height.
Definition: pt_data.h:89
int get_start_time() const
Gets start time of track.
Definition: mcmcda_track.h:93
const Laplace_distribution & bg_x_dist() const
Return the individual Laplace distribution for x.
Definition: pt_optical_flow_likelihood.h:84
double kappa() const
Get average number of before start of video.
Definition: mcmcda_prior.h:79
virtual void set_camera_centre_y(double iy)
sets the y-coordinate of the camera centre
Definition: perspective_camera.cpp:751
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
const Normal_distribution & mouth_x_dist() const
Definition: pt_facemark_likelihood.h:116
double visible
Definition: pt_visibility.h:41
Axis_aligned_rectangle_2d Bbox
Definition: d_bbox.h:29
const Position_prior & position_prior() const
Returns the position prior.
Definition: pt_scene_posterior.h:163
bool pixel_visible(int x, int y, const Visibility &vis)
Helper function that determines if a pixel is visible.
Definition: pt_scene_generative_model.h:57
double theta
Definition: pt_scene.h:62
const Normal_distribution & width_prior() const
Returns the width prior.
Definition: pt_scene_posterior.h:178
Vector right_mouth
Definition: pt_face_2d.h:44
double lambda_N() const
Get false detection rate.
Definition: mcmcda_prior.h:85
Vector sample(const MV_gaussian_distribution &dist)
Sample from a multivariate normal distribution.
Definition: prob_sample.cpp:42
void update_visibilities(const Scene &scene, bool infer_head=true)
Update all the visibilities in a scene.
Definition: pt_visibility.cpp:62
Parent::iterator iterator
Definition: mcmcda_track.h:80
Value_type mean(Iterator begin, Iterator end, const Value_type &)
Definition: prob_stat.h:56
Visibility visibility
Definition: pt_face_2d.h:46
Represents the information regarding visibility of an actor at a given frame and given all other acto...
Definition: pt_visibility.h:38
double cell_width
Definition: pt_visibility.h:42
void update_fdir_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:225
boost::math::laplace Laplace_distribution
Definition: prob_distribution.h:67
const Normal_distribution & eye_x_dist() const
Definition: pt_facemark_likelihood.h:112
2D face information resulting from projecting the 3D head/face.
Definition: pt_face_2d.h:37
const Normal_distribution & height_prior() const
Returns the height prior.
Definition: pt_scene_posterior.h:175
St_perspective_camera for modeling a perspective camera using the classic Forsyth and Ponce parametri...
double signal_variance() const
Return the GP signal variance.
Definition: pt_direction_prior.h:99
const Gpp & fdir_prior() const
Returns the prior distribution used to evaluate this target.
Definition: pt_target.h:115
double scale() const
Return the GP scale.
Definition: pt_direction_prior.h:96
Definition: perspective_camera.h:93
x
Definition: APPgetLargeConnectedEdges.m:100
Vector & set(Value_type val)
Clone of zero_out(int)
Definition: m_vector.h:707
Class that represents the prior distribution of a trajectory.
Definition: pt_position_prior.h:34
Class that represents a target moving through space.
Definition: pt_target.h:50
const Vector & get_center() const
returns the center of this Axis_aligned_rectangle_2d
Definition: gr_2D_bounding_box.h:80
const Data< Element > & get_data() const
Returns data set const-ref.
Definition: mcmcda_association.h:126
Class that represents likelihood of a set of projected boxes given. detections. At the moment it only...
Definition: pt_box_likelihood.h:42
Perspective_camera camera
Definition: pt_scene.h:60
const Box_likelihood & box_likelihood() const
Returns the box likelihood.
Definition: pt_scene_posterior.h:184
virtual void set_pitch(double ipitch)
sets the pitch angle in radian
Definition: perspective_camera.cpp:771
const Laplace_distribution & y_dist() const
Return the individual Laplace distribution for y.
Definition: pt_optical_flow_likelihood.h:81
const Normal_distribution & nose_x_dist() const
Definition: pt_facemark_likelihood.h:114
Body_2d_trajectory & body_trajectory() const
Get this target's current 2D body trajectory.
Definition: pt_target.h:91
Class that represents the camera prior.
Definition: pt_camera_prior.h:31
void sync_state(const Target &tg)
Sync targets trajectory with endpoints.
Definition: pt_target.cpp:624
const Normal_distribution & girth_prior() const
Returns the girth prior.
Definition: pt_scene_posterior.h:181
double scale() const
Return the GP scale.
Definition: pt_direction_prior.h:200
std::pair< std::vector< Track >, std::vector< size_t > > sample(const Prior< Track > &prior, size_t T, const Track &def)
Sample an association from the prior.
Definition: mcmcda_prior.h:193
Posterior distribution of a scene.
Definition: pt_scene_posterior.h:53
double get_left() const
Definition: gr_2D_bounding_box.h:97
double get_top() const
Definition: gr_2D_bounding_box.h:100
double theta() const
Get average track length.
Definition: mcmcda_prior.h:82
Bbox full_bbox
Definition: pt_body_2d.h:37
#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
const Normal_distribution & height_prior() const
Definition: pt_camera_prior.h:55
boost::math::normal Normal_distribution
Definition: prob_distribution.h:68
Sampling functionality for the different distributions defined in "prob_distributions.h".
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
Definition: flow_integral_flow.h:38
const Normal_distribution & nose_y_dist() const
Definition: pt_facemark_likelihood.h:115
void sample(const mcmcda::Prior< Target > &w_prior, const Camera_prior &cam_prior, const Scene_posterior &posterior, size_t T, Scene &scene, Box_data &box_data, FmvIterator fm_out, FlowOutIterator xflow_out, FlowOutIterator yflow_out, size_t max_tracks=0)
Sample from full generative model.
Definition: pt_scene_generative_model.h:511
void unstandardize(Vector &v, double cam_width, double cam_height)
Changes vector to unstandard (image) coordinate system.
Definition: pt_util.h:83
void sample(const Position_prior &pos_prior, const Direction_prior &dir_prior, const Face_direction_prior &fdir_prior, const Normal_distribution &height_prior, const Normal_distribution &width_prior, const Normal_distribution &girth_prior, TargetIterator first, TargetIterator last)
Sample a scene from the prior (and a given sequence of tracks).
Definition: pt_scene_generative_model.h:109
void update_faces(const Perspective_camera &cam) const
Update face trajectory.
Definition: pt_target.cpp:551
const Normal_distribution & focal_length_prior() const
Definition: pt_camera_prior.h:57
const Direction_prior & direction_prior() const
Returns the direction prior.
Definition: pt_scene_posterior.h:166
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
double scale() const
Return the GP scale.
Definition: pt_position_prior.h:105
Class to compute facemark likelihood.
Definition: pt_facemark_likelihood.h:39
double get_rectangle_intersection(const kjb::Bounding_Box2D &b1, const kjb::Bounding_Box2D &b2)
Compute area of intersection of two rectangles.
Definition: gr_2D_bounding_box.cpp:282
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
boost::math::uniform Uniform_distribution
Definition: prob_distribution.h:70
double girth
Definition: tracking_trajectory.h:197
Parent::value_type value_type
Definition: mcmcda_track.h:84
const Normal_distribution & pitch_prior() const
Definition: pt_camera_prior.h:56
void get_params(const std::string &type, Vector &params_x, Vector &params_top, Vector &params_bot) const
Computes line paramters given type of box.
Definition: pt_box_likelihood.cpp:136
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
std::vector< Vector > visible_cells
Definition: pt_visibility.h:40
void fix_target(Target &target, double imw, double imh)
Helper function that fixes a track when it leaves the view.
Definition: pt_scene_generative_model.h:76
void update_dir_gp(double sc, double sv) const
Updates internal distribution and caching mechanism.
Definition: pt_target.h:219
double width
Definition: tracking_trajectory.h:196
double signal_variance() const
Return the GP signal variance.
Definition: pt_direction_prior.h:203
double cell_height
Definition: pt_visibility.h:43
double kappa
Definition: pt_scene.h:61