gaze  0.1.0
Perform gaze tracking with common webcams.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
gaze_point_calculation.h
1 #ifndef INCLUDE_GAZE_PIPELINE_STEPS_GAZE_POINT_CALCULATION_H_
2 #define INCLUDE_GAZE_PIPELINE_STEPS_GAZE_POINT_CALCULATION_H_
3 
4 #include <string>
5 #include <vector>
6 
7 #include "opencv2/opencv.hpp"
8 
9 #include "gaze/gui/visualizeable.h"
10 #include "gaze/pipeline_step.h"
11 #include "gaze/util/data.h"
12 
13 
14 namespace gaze {
15 
16 namespace util {
17 
28 double parse_aspect_ratio(std::string aspect_ratio_string);
29 
41 double clamp(double value, double min, double max);
42 
43 } // namespace util
44 
45 namespace pipeline {
46 
54  : public PipelineStep,
56  double focal_length;
57  double sensor_height;
58  double sensor_width;
59  double pixel_height;
60  double pixel_width;
61  cv::Matx33d camera_matrix;
62  cv::Mat distortion_coefficients;
63  std::vector<cv::Vec3d> eye_ball_centers;
65  std::vector<decltype(util::Data::landmarks.num_parts())> landmark_indices;
66  double screen_width_m;
67  double screen_height_m;
68  double screen_width_px;
69  double screen_height_px;
70  double target_width;
71  double target_height;
72  double camera_offset_x;
73  double camera_offset_y;
74 
87  double calculate_distance(const dlib::point& p0, const dlib::point& p1,
88  double expected_model_distance);
89 
98  cv::Matx34d invertProjection(const std::vector<cv::Vec3d>& landmarks);
99 
113  std::vector<cv::Vec3d> unprojectPoints(
114  const std::vector<cv::Vec2d>& points, const cv::Vec3d& translation,
115  const cv::Matx33d& rotation, double distance);
116 
126  cv::Vec3d get_model_to_camera_dir(
127  const cv::Vec3d& translation, const cv::Matx33d& rotation);
128 
137  cv::Vec3d get_camera_pos(const cv::Vec3d& get_model_to_camera_dir,
138  double distance);
139 
149  std::vector<cv::Vec3d> get_screen_corners(
150  const cv::Vec3d& camera_pos, const cv::Matx33d& rotation);
151 
192  cv::Matx32d calculate_gaze_point(
193  const cv::Vec3d& eye_ball_center, const cv::Vec3d& pupil,
194  const cv::Vec3d& screen_a, const cv::Vec3d& screen_b,
195  const cv::Vec3d& screen_c);
196 
197  protected:
202  void set_sensor_size(double sensor_diagonal, double aspect_ratio);
203 
204  public:
206 
213  void process(util::Data& data) override;
214 
220  void visualize(util::Data& data) override;
221 };
222 
223 } // namespace pipeline
224 
225 } // namespace gaze
226 
227 #endif // INCLUDE_GAZE_PIPELINE_STEPS_GAZE_POINT_CALCULATION_H_
_Tp max() const
double parse_aspect_ratio(std::string aspect_ratio_string)
void distance(_InputIterator __first, _InputIterator __last, _Distance &__n)
Abstract base class for PipelineSteps. Must be inherited from.
Definition: pipeline_step.h:18
void visualize(util::Data &data) override
Implements VisualizeableBase for several widget types.
void set_sensor_size(double sensor_diagonal, double aspect_ratio)
dlib::full_object_detection landmarks
Definition: data.h:64
double clamp(double value, double min, double max)
Wraps the data acquired per frame into a single instance.
Definition: data.h:27
void process(util::Data &data) override
_Tp min() const