KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_box_likelihood.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: pt_box_likelihood.h 18657 2015-03-18 14:43:48Z ernesto $ */
22 
23 #ifndef PT_BOX_LIKELIHOOD_H_
24 #define PT_BOX_LIKELIHOOD_H_
25 
30 #include <detector_cpp/d_bbox.h>
31 #include <cmath>
32 #include <string>
33 
34 namespace kjb {
35 namespace pt {
36 
43 {
44 public:
46  (
47  double noise_weight,
48  double image_width,
49  double image_height,
50  const std::string& dist_name = std::string("laplace")
51  ) :
52  noise_weight_(noise_weight),
53  image_width_(image_width),
54  image_height_(image_height),
55  m_dist_name(dist_name)
56  {}
57 
59  double operator()(const Scene& scene) const;
60 
62  double at_noise(const Scene& scene) const;
63 
65  double at_target(const Target& target) const;
66 
68  double at_frame(const Target& target, size_t frame) const;
69 
71  double at_model(const Detection_box& dbox, const Body_2d& model) const;
72 
74  void get_params
75  (
76  const std::string& type,
77  Vector& params_x,
78  Vector& params_top,
79  Vector& params_bot
80  ) const;
81 
82 private:
84  double single_box(const Detection_box& dbox, const Bbox& mbox) const;
85 
87  double single_noise(const Detection_box& /* dbox */) const
88  {
89  return noise_weight_ * (-std::log(image_width_)
90  - std::log(image_height_)
91  - std::log(image_height_));
92  }
93 
94  /*
95  * @brief Helper function that computes PDF of value given line
96  * parameters.
97  */
98  double get_log_pdf
99  (
100  const Vector& params,
101  const std::string& dist_name,
102  double model_height,
103  double value
104  ) const;
105 
106 private:
107  double noise_weight_;
108  double image_width_;
109  double image_height_;
110  std::string m_dist_name;
111 };
112 
113 }} //namespace kjb::pt
114 
115 #endif /*PT_BOX_LIKELIHOOD_H_ */
116 
Class that represents a detection bounding box from any source.
Definition: pt_detection_box.h:42
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 at_target(const Target &target) const
Evaluate this log-likelihood on the given target.
Definition: pt_box_likelihood.cpp:74
double at_noise(const Scene &scene) const
Evaluate this log-likelihood on the given scene.
Definition: pt_box_likelihood.cpp:54
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
2D body information resulting from projecting the 3D body.
Definition: pt_body_2d.h:35
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
double at_model(const Detection_box &dbox, const Body_2d &model) const
Evaluate this log-likelihood on the given frame.
Definition: pt_box_likelihood.cpp:111
Box_likelihood(double noise_weight, double image_width, double image_height, const std::string &dist_name=std::string("laplace"))
Definition: pt_box_likelihood.h:46
Class that represents a target moving through space.
Definition: pt_target.h:50
Class that represents likelihood of a set of projected boxes given. detections. At the moment it only...
Definition: pt_box_likelihood.h:42
double operator()(const Scene &scene) const
Evaluate this log-likelihood on the given scene.
Definition: pt_box_likelihood.cpp:41
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
double at_frame(const Target &target, size_t frame) const
Evaluate this log-likelihood on the given frame.
Definition: pt_box_likelihood.cpp:91