1 #include "gaze/gaze_tracker.h"
8 #include "yaml-cpp/yaml.h"
10 #include "gaze/gui/debug_window.h"
11 #include "gaze/pipeline.h"
12 #include "gaze/pipeline_step.h"
13 #include "gaze/pipeline_steps.h"
14 #include "gaze/util/config.h"
22 subject_id(subject_id) {
23 this->initialized =
false;
24 this->
init(subject_id, debug);
27 GazeTracker::~GazeTracker() {
28 if (this->initialized) {
29 delete this->pipeline;
37 if (!this->initialized) {
45 if (!this->initialized) {
46 std::cerr <<
"[GazeTracker] Not initialized (get_current_gaze_point())." <<
59 if (this->initialized) {
63 this->subject_id = subject_id;
64 this->init_pipeline(subject_id);
66 gui::open_debug_window(this->pipeline);
68 this->initialized =
true;
71 void GazeTracker::init_pipeline(
const std::string subject_id) {
72 if (this->initialized) {
77 for (YAML::Node step_config : config) {
81 step =
new pipeline::EyeLike();
82 }
else if (!type.
compare(
"FaceLandmarks")) {
83 step =
new pipeline::FaceLandmarks();
84 }
else if (!type.
compare(
"GazePointCalculation")) {
85 step =
new pipeline::GazePointCalculation();
86 }
else if (!type.
compare(
"GazeCapture")) {
87 step =
new pipeline::GazeCapture();
88 }
else if (!type.
compare(
"HeadPoseEstimation")) {
89 step =
new pipeline::HeadPoseEstimation();
90 }
else if (!type.
compare(
"PupilLocalization")) {
91 step =
new pipeline::PupilLocalization();
92 }
else if (!type.
compare(
"SourceCapture")) {
93 step =
new pipeline::SourceCapture();
95 step =
new pipeline::FallbackStep();
98 this->pipeline_steps.push_back(step);
100 this->pipeline =
new Pipeline(this->pipeline_steps,
true);
104 if (!this->initialized) {
105 std::cerr <<
"[GazeTracker] Not initialized (start_trial())." <<
109 this->current_trial_id = identifier;
110 std::cout <<
"[GazeTracker] [Stub] Starting trial " << this->current_trial_id
115 if (!this->initialized) {
116 std::cerr <<
"[GazeTracker] Not initialized (stop_trial())." <<
120 std::cout <<
"[GazeTracker] [Stub] Stopping trial " << this->current_trial_id
122 this->current_trial_id =
"";
void init(const std::string subject_id, const bool debug=false)
Abstract base class for PipelineSteps. Must be inherited from.
const std::pair< int, int > get_current_gaze_point() const
cv::Vec2d estimated_gaze_point
void start_trial(const std::string identifier)
GazeTracker(const std::string subject_id="default_subject", const bool debug=false)
int compare(const basic_string &__str) const
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)