gaze  0.1.0
Perform gaze tracking with common webcams.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
pipeline_utils.cpp
1 #include "gaze/util/pipeline_utils.h"
2 
3 #include <vector>
4 
5 #include "dlib/image_transforms.h"
6 
7 
8 namespace gaze {
9 
10 namespace util {
11 
13  const dlib::full_object_detection object_detection) {
15  if (object_detection.num_parts() < 5) {
16  return details;
17  }
18 
19  auto get_rectangle = [](dlib::point one, dlib::point two)
20  -> dlib::rectangle {
21  dlib::rectangle result(one, two);
22  double scale = (one - two).length() * 1.5;
23  return dlib::centered_rect(result, scale, scale);
24  };
25 
26  int index_ex_left;
27  int index_en_left;
28  int index_ex_right;
29  int index_en_right;
30  if (object_detection.num_parts() == 5) {
31  index_ex_left = 2;
32  index_en_left = 3;
33  index_ex_right = 0;
34  index_en_right = 1;
35  } else { // 68 landmarks
36  index_ex_left = 45;
37  index_en_left = 42;
38  index_ex_right = 36;
39  index_en_right = 39;
40  }
41 
42  details.push_back(dlib::chip_details(
43  get_rectangle(object_detection.part(index_ex_right),
44  object_detection.part(index_en_right))));
45  details.push_back(dlib::chip_details(
46  get_rectangle(object_detection.part(index_ex_left),
47  object_detection.part(index_en_left))));
48 
49  return details;
50 }
51 
52 } // namespace util
53 
54 } // namespace gaze
std::vector< dlib::chip_details > get_eyes_chip_details(const dlib::full_object_detection object_detection)
void rectangle(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
void push_back(const value_type &__x)
static softfloat one()