KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
d_deva_detection.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 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  | Author: Kyle Simek, Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: d_deva_detection.h 18278 2014-11-25 01:42:10Z ksimek $ */
20 
21 
22 #ifndef D_DEVA_DETECTION_H
23 #define D_DEVA_DETECTION_H
24 
25 #include <detector_cpp/d_bbox.h>
27 
28 #include <string>
29 #include <vector>
30 #include <iostream>
31 
32 namespace kjb
33 {
34 
42 {
43 
44 public:
45 
46  Deva_detection() : boxes_(9){}
47 
49  (
50  double score,
51  const std::vector<Bbox>& boxes,
52  std::string type
53  ) : score_(score),
54  boxes_(boxes),
55  type_(type)
56  {}
57 
58  const Bbox& full_body() const { return boxes_[0]; }
59  const Bbox& rhead() const { return boxes_[1]; }
60  const Bbox& lhead() const { return boxes_[2]; }
61  const Bbox& rshoulder() const { return boxes_[3]; }
62  const Bbox& lshoulder() const { return boxes_[4]; }
63  const Bbox& rhip() const { return boxes_[5]; }
64  const Bbox& lhip() const { return boxes_[6]; }
65  const Bbox& rfoot() const { return boxes_[7]; }
66  const Bbox& lfoot() const { return boxes_[8]; }
67  const Bbox& operator[] (size_t i) const
68  {
69  if( i > 8)
70  {
72  "Index out of bound in Deva_detection ");
73  }
74  return boxes_[i];
75  }
76 
77  Bbox& full_body() { return boxes_[0]; }
78  Bbox& rhead() { return boxes_[1]; }
79  Bbox& lhead() { return boxes_[2]; }
80  Bbox& rshoulder() { return boxes_[3]; }
81  Bbox& lshoulder() { return boxes_[4]; }
82  Bbox& rhip() { return boxes_[5]; }
83  Bbox& lhip() { return boxes_[6]; }
84  Bbox& rfoot() { return boxes_[7]; }
85  Bbox& lfoot() { return boxes_[8]; }
86  Bbox& operator[] (size_t i)
87  {
88  if( i > 8)
89  {
91  "Index out of bound in Deva_detection ");
92  }
93  return boxes_[i];
94  }
95  size_t size() { return boxes_.size(); }
96 
97  double score() const { return score_; }
98  double& score() { return score_; }
99 
100  const std::string& type() const { return type_; }
101  std::string& type() { return type_; }
102 
103  double probability_of_noise() const;
104 
105 private:
106  double score_;
107  std::vector<Bbox> boxes_;
108  std::string type_;
109 };
110 
115 std::vector<Deva_detection> parse_deva_detection
116 (
117  std::istream& is,
118  const std::string& type = std::string("person")
119 );
120 
125 std::vector<Deva_detection> parse_deva_detection
126 (
127  std::istream& is,
128  double score_thresh,
129  const std::string& type = std::string("person")
130 );
131 
135 Deva_detection parse_deva_detection_line
136 (
137  const std::string& line,
138  const std::string& type = std::string("person")
139 );
140 
143 {
144 public:
146  : compared_center(center)
147  {}
148 
149  bool operator()
150  (
151  const Deva_detection& box_1,
152  const Deva_detection& box_2
153  )
154  {
155  const Vector& center_1 = box_1.full_body().get_center();
156  const Vector& center_2 = box_2.full_body().get_center();
157 
158  // Only compare the distance between the Deva detection
159  // and the compared box center for now
160  return vector_distance(center_1, compared_center) <
161  vector_distance(center_2, compared_center);
162  }
163 
164 private:
165  Vector compared_center;
166 };
167 
168 } // namespace kjb
169 
170 #endif /* D_DEVA_DETECTION_H */
Bbox & full_body()
Definition: d_deva_detection.h:77
std::vector< Deva_detection > parse_deva_detection(std::istream &is, const std::string &type=std::string("person"))
Parse the output from Deva's part detector into a vector of Deva_detection.
Definition: d_deva_detection.cpp:85
double score() const
Definition: d_deva_detection.h:97
const std::string & type() const
Definition: d_deva_detection.h:100
double vector_distance(const Int_vector &op1, const Int_vector &op2)
Compute the Euclidian distance between two vectors.
Definition: l_int_vector.h:1569
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 & score()
Definition: d_deva_detection.h:98
double probability_of_noise() const
Definition: d_deva_detection.cpp:37
Object thrown when an index argument exceeds the size of a container.
Definition: l_exception.h:399
const Bbox & lhip() const
Definition: d_deva_detection.h:64
std::string & type()
Definition: d_deva_detection.h:101
Bbox & lhip()
Definition: d_deva_detection.h:83
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Compare_box_distance(const Vector &center)
Definition: d_deva_detection.h:145
const Bbox & rshoulder() const
Definition: d_deva_detection.h:61
const Bbox & lshoulder() const
Definition: d_deva_detection.h:62
Definition: d_deva_detection.h:41
size_t size()
Definition: d_deva_detection.h:95
St_perspective_camera for modeling a perspective camera using the classic Forsyth and Ponce parametri...
Bbox & lshoulder()
Definition: d_deva_detection.h:81
Bbox & rhead()
Definition: d_deva_detection.h:78
Deva_detection parse_deva_detection_line(const std::string &line, const std::string &type=std::string("person"))
Parse the output from Deva's part detector.
Definition: d_deva_detection.cpp:131
Bbox & rfoot()
Definition: d_deva_detection.h:84
Deva_detection()
Definition: d_deva_detection.h:46
const Bbox & rhip() const
Definition: d_deva_detection.h:63
const Bbox & full_body() const
Definition: d_deva_detection.h:58
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
const Bbox & rfoot() const
Definition: d_deva_detection.h:65
const Bbox & rhead() const
Definition: d_deva_detection.h:59
const Bbox & lhead() const
Definition: d_deva_detection.h:60
Bbox & lhead()
Definition: d_deva_detection.h:79
const Bbox & operator[](size_t i) const
Definition: d_deva_detection.h:67
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
Bbox & rhip()
Definition: d_deva_detection.h:82
Functor for comparing box distance.
Definition: d_deva_detection.h:142
Bbox & lfoot()
Definition: d_deva_detection.h:85
Bbox & rshoulder()
Definition: d_deva_detection.h:80
const Bbox & lfoot() const
Definition: d_deva_detection.h:66