KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_color_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 * =========================================================================== */
17 
18 /* $Id: pt_color_likelihood.h 18657 2015-03-18 14:43:48Z ernesto $ */
19 
20 #ifndef PT_COLOR_LIKELIHOOD_H_
21 #define PT_COLOR_LIKELIHOOD_H_
22 
25 #include <i_cpp/i_filter.h>
26 #include <m_cpp/m_vector.h>
27 #include <m_cpp/m_matrix.h>
28 #include <detector_cpp/d_bbox.h>
29 #include <vector>
30 #include <string>
31 #include <utility>
32 #include <boost/shared_array.hpp>
33 
34 namespace kjb {
35 namespace pt {
36 
43 {
44 public:
45  // Ctor
47  (
48  size_t pixel_sampling = 1,
49  size_t frame_sampling = 1
50  ) : m_bg_r_p(NULL),
51  m_bg_g_p(NULL),
52  m_pixel_ssz(pixel_sampling),
53  m_frame_ssz(frame_sampling)
54  {}
55 
57  double operator()(const Scene& scene) const;
58 
60  double at_trajectory(const Target& target) const;
61 
63  double at_box
64  (
65  const Body_2d& cur_b2d,
66  const Body_2d& next_b2d,
67  size_t cur_frame,
68  size_t next_frame
69  ) const;
70 
71  void read_frames(const std::vector<std::string>& frame_fps);
72 
73  void set_bg_r_matrix(const Matrix* bg_r_p)
74  {
75  m_bg_r_p = bg_r_p;
76  }
77 
78  void set_bg_g_matrix(const Matrix* bg_g_p)
79  {
80  m_bg_g_p = bg_g_p;
81  }
82 
83 private:
84  std::vector<Vector> get_foreground
85  (
86  size_t frame,
87  const Bbox& box
88  ) const;
89 
90  std::vector<Vector> get_background
91  (
92  const Bbox& box
93  ) const;
94 
95  Matrix get_norm_hist_as_matrix
96  (
97  const Vector& loc,
98  double x_delta,
99  double y_delta,
100  size_t frame,
101  const std::pair<double, double>& range_1,
102  const std::pair<double, double>& range_2,
103  size_t num_bins,
104  const Filter& filter,
105  bool is_foreground
106  ) const;
107 
108 private:
109  const Matrix* m_bg_r_p;
110  const Matrix* m_bg_g_p;
111  std::vector<boost::shared_array<float> > m_r_pixels;
112  std::vector<boost::shared_array<float> > m_g_pixels;
113  size_t m_pixel_ssz;
114  size_t m_frame_ssz;
115  size_t m_width;
116  size_t m_height;
117 
118 };
119 
120 }} //namespace kjb::pt
121 
122 #endif /* PT_COLOR_LIKELIHOOD_H_ */
123 
double operator()(const Scene &scene) const
Evaluate this likelihood at the given scene.
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center...
Definition: gr_2D_bounding_box.h:51
void set_bg_g_matrix(const Matrix *bg_g_p)
Definition: pt_color_likelihood.h:78
void read_frames(const std::vector< std::string > &frame_fps)
Definition: pt_color_likelihood.cpp:43
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
Color_likelihood(size_t pixel_sampling=1, size_t frame_sampling=1)
Definition: pt_color_likelihood.h:47
Code for a wrapper class around the C struct KJB_Filter.
Class that represents a target moving through space.
Definition: pt_target.h:50
Filter class.
Definition: i_filter.h:36
double at_box(const Body_2d &cur_b2d, const Body_2d &next_b2d, size_t cur_frame, size_t next_frame) const
Evaluate likelihood at a single box.
Definition: pt_color_likelihood.cpp:133
Class that represents color likelihood of a set of projected boxes given detections.
Definition: pt_color_likelihood.h:42
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
void set_bg_r_matrix(const Matrix *bg_r_p)
Definition: pt_color_likelihood.h:73
double at_trajectory(const Target &target) const
Evaluate likelihood at boxes of a trajectory.
Definition: pt_color_likelihood.cpp:106