KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_facemark_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 | Jinyan Guan
18 |
19 * =========================================================================== */
20 
21 /* $Id: pt_facemark_likelihood.h 18873 2015-04-17 03:00:10Z ernesto $ */
22 
23 #ifndef PT_FACEMARK_LIKELIHOOD_H_
24 #define PT_FACEMARK_LIKELIHOOD_H_
25 
29 #include <m_cpp/m_vector.h>
31 #include <l_cpp/l_util.h>
32 
33 namespace kjb {
34 namespace pt {
35 
40 {
41 public:
44  (
45  const Facemark_data& fm_data,
46  double eye_x_sigma,
47  double eye_y_sigma,
48  double nose_x_sigma,
49  double nose_y_sigma,
50  double mouth_x_sigma,
51  double mouth_y_sigma,
52  double img_width,
53  double img_height
54  ) :
55  m_fm_data(fm_data),
56  m_eye_x_dist(0.0, eye_x_sigma),
57  m_eye_y_dist(0.0, eye_y_sigma),
58  m_nose_x_dist(0.0, nose_x_sigma),
59  m_nose_y_dist(0.0, nose_y_sigma),
60  m_mouth_x_dist(0.0, mouth_x_sigma),
61  m_mouth_y_dist(0.0, mouth_y_sigma),
62  m_img_width(img_width),
63  m_img_height(img_height)
64  {}
65 
68  (
69  const Facemark_data& fm_data,
70  double sigma,
71  double img_width,
72  double img_height
73  ) :
74  m_fm_data(fm_data),
75  m_eye_x_dist(0.0, sigma),
76  m_eye_y_dist(0.0, sigma),
77  m_nose_x_dist(0.0, sigma),
78  m_nose_y_dist(0.0, sigma),
79  m_mouth_x_dist(0.0, sigma),
80  m_mouth_y_dist(0.0, sigma),
81  m_img_width(img_width),
82  m_img_height(img_height)
83  {}
84 
86  double operator()(const Scene& scene) const;
87 
89  double at_noise(const Scene& scene) const
90  {
91  size_t nnfaces = num_facemarks() - num_assigned_facemarks(scene);
92  return 5 * nnfaces * single_noise();
93  }
94 
96  double at_trajectory(const Target& target) const;
97 
99  double at_face(const Face_2d& face) const;
100 
101  double single_noise() const
102  {
103  return -log(m_img_width) - log(m_img_height);
104  }
105 
107  size_t num_assigned_facemarks(const Scene& scene) const;
108 
110  size_t num_facemarks() const { return length(m_fm_data); }
111 
112  const Normal_distribution& eye_x_dist() const { return m_eye_x_dist; }
113  const Normal_distribution& eye_y_dist() const { return m_eye_y_dist; }
114  const Normal_distribution& nose_x_dist() const { return m_nose_x_dist; }
115  const Normal_distribution& nose_y_dist() const { return m_nose_y_dist; }
116  const Normal_distribution& mouth_x_dist() const { return m_mouth_x_dist; }
117  const Normal_distribution& mouth_y_dist() const { return m_mouth_y_dist; }
118 
119 private:
120  double at_mark
121  (
122  const Vector& dmark,
123  const Vector& fmark,
124  const Normal_distribution& P_x,
125  const Normal_distribution& P_y
126  ) const;
127 
128 
129 private:
130  // data members
131  const Facemark_data& m_fm_data;
132  Normal_distribution m_eye_x_dist;
133  Normal_distribution m_eye_y_dist;
134  Normal_distribution m_nose_x_dist;
135  Normal_distribution m_nose_y_dist;
136  Normal_distribution m_mouth_x_dist;
137  Normal_distribution m_mouth_y_dist;
138  double m_img_width;
139  double m_img_height;
140 };
141 
142 }} //namespace kjb::pt
143 
144 #endif /*PT_FACEMARK_LIKELIHOOD_H_ */
145 
const Normal_distribution & eye_y_dist() const
Definition: pt_facemark_likelihood.h:113
Definition of various standard probability distributions.
const Normal_distribution & mouth_y_dist() const
Definition: pt_facemark_likelihood.h:117
Facemark_likelihood(const Facemark_data &fm_data, double eye_x_sigma, double eye_y_sigma, double nose_x_sigma, double nose_y_sigma, double mouth_x_sigma, double mouth_y_sigma, double img_width, double img_height)
Construct an Facemark_likelihood with the given parameters.
Definition: pt_facemark_likelihood.h:44
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
double single_noise() const
Definition: pt_facemark_likelihood.h:101
size_t num_assigned_facemarks(const Scene &scene) const
Returns the number of assigned faces.
Definition: pt_facemark_likelihood.cpp:122
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
size_t length(const C &cner)
Counts the total number of elements in a 2D STL-style container.
Definition: l_util.h:17
double at_trajectory(const Target &target) const
Evaluate likelihood at boxes of a trajectory.
Definition: pt_facemark_likelihood.cpp:43
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
std::vector< std::vector< Deva_facemark > > Facemark_data
Definition: pt_data.h:129
double at_noise(const Scene &scene) const
Evaluate the noise likelihood at the given scene.
Definition: pt_facemark_likelihood.h:89
Class that represents a target moving through space.
Definition: pt_target.h:50
double at_face(const Face_2d &face) const
Evaluate likelihood at a single box.
Definition: pt_facemark_likelihood.cpp:61
const Normal_distribution & nose_x_dist() const
Definition: pt_facemark_likelihood.h:114
boost::math::normal Normal_distribution
Definition: prob_distribution.h:68
const Normal_distribution & nose_y_dist() const
Definition: pt_facemark_likelihood.h:115
size_t num_facemarks() const
Returns the total number of faces.
Definition: pt_facemark_likelihood.h:110
Class to compute facemark likelihood.
Definition: pt_facemark_likelihood.h:39
double operator()(const Scene &scene) const
Evaluate this likelihood at the given scene.
Definition: pt_facemark_likelihood.cpp:30
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...