gaze  0.1.0
Perform gaze tracking with common webcams.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Public Member Functions | List of all members
gaze::GazeTracker Class Reference

This class wraps the gaze tracking process. More...

#include "gaze/gaze_tracker.h"

Public Member Functions

 GazeTracker (const std::string subject_id="default_subject", const bool debug=false)
 
void calibrate ()
 
Data access
const std::pair< int, int > get_current_gaze_point () const
 
Initialization

This method allows initialization of a GazeTracker instance. If GazeTracker() was used to construct the instance, you must call either of these functions before perfoming any actions.

void init (const std::string subject_id, const bool debug=false)
 
Trial handling

These functions are used to partition an experiment into trials. When you start a trial, call the GazeTracker::start_trial(const std::string) method. After the trial you should issue GazeTracker::stop_trial().

Note that the GazeTracker keeps tracking until you destroy the instance, the only difference in calling the start and stop trial functions is that the identifier will be available next to the data for the specific trial.

void start_trial (const std::string identifier)
 
void stop_trial ()
 

Detailed Description

This class wraps the gaze tracking process.

This is the GazeTracker, the heart of gaze. It allows for easy initialization, tracking, and trial definitions.

Definition at line 24 of file gaze_tracker.h.

Constructor & Destructor Documentation

gaze::GazeTracker::GazeTracker ( const std::string  subject_id = "default_subject",
const bool  debug = false 
)

Constructs and initializes a GazeTracker instance for a video source. See GazeTracker::init(std::string, std::string, std::string).

Parameters
subject_idThe subject identifier.
debugStarts the gaze_tracker in debug mode, bringing up additional debuggin screens.

Definition at line 19 of file gaze_tracker.cpp.

References init().

21  : debug(debug),
22  subject_id(subject_id) {
23  this->initialized = false;
24  this->init(subject_id, debug);
25 }
void init(const std::string subject_id, const bool debug=false)

Member Function Documentation

void gaze::GazeTracker::calibrate ( )

Calibrates the GazeTracker.

Note
Currently there is no calibration phase.

Definition at line 36 of file gaze_tracker.cpp.

References std::cerr, std::cout, and std::endl().

36  {
37  if (!this->initialized) {
38  std::cerr << "[GazeTracker] Not initialized (calibrate())." << std::endl;
39  return;
40  }
41  std::cout << "[GT Stub] Calibrating." << std::endl;
42 }
ostream cerr
ostream cout
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
const std::pair< int, int > gaze::GazeTracker::get_current_gaze_point ( ) const
Returns
the most recent calculated gaze point. If not initialized, returns $(-1, -1)$.

Definition at line 44 of file gaze_tracker.cpp.

References std::cerr, std::endl(), gaze::util::Data::estimated_gaze_point, and gaze::Pipeline::get_data().

44  {
45  if (!this->initialized) {
46  std::cerr << "[GazeTracker] Not initialized (get_current_gaze_point())." <<
47  std::endl;
48  return std::pair<int, int>(-1, -1);
49  }
50  int x =
51  static_cast<int>(this->pipeline->get_data().estimated_gaze_point(0));
52  int y =
53  static_cast<int>(this->pipeline->get_data().estimated_gaze_point(1));
54  return std::pair<int, int>(x, y);
55 }
ostream cerr
util::Data get_data()
Definition: pipeline.cpp:69
cv::Vec2d estimated_gaze_point
Definition: data.h:105
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
void gaze::GazeTracker::init ( const std::string  subject_id,
const bool  debug = false 
)

Initializes the GazeTracker.

It immediately starts tracking.

Parameters
subject_idThe subject ID, used to store the data in the correct file.
debugStarts the gaze_tracker in debug mode, bringing up additional debuggin screens.

Definition at line 57 of file gaze_tracker.cpp.

Referenced by GazeTracker().

58  {
59  if (this->initialized) {
60  return;
61  }
62  this->debug = debug;
63  this->subject_id = subject_id;
64  this->init_pipeline(subject_id);
65  if (this->debug) {
66  gui::open_debug_window(this->pipeline);
67  }
68  this->initialized = true;
69 }
void gaze::GazeTracker::start_trial ( const std::string  identifier)

Makes the GazeTracker associate its output data with the identifier until either GazeTracker::stop_trial() is called or a new trial is started by calling this function with a different identifier.

The identifiers are not checked for uniqueness! It is very well possible to use the same identifier multiple tames, analyzing the data correctly is then up to you.

Parameters
identifierThe trial identifier.

Definition at line 103 of file gaze_tracker.cpp.

References std::cerr, std::cout, and std::endl().

103  {
104  if (!this->initialized) {
105  std::cerr << "[GazeTracker] Not initialized (start_trial())." <<
106  std::endl;
107  return;
108  }
109  this->current_trial_id = identifier;
110  std::cout << "[GazeTracker] [Stub] Starting trial " << this->current_trial_id
111  << std::endl;
112 }
ostream cerr
ostream cout
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
void gaze::GazeTracker::stop_trial ( )

Stops associating data with any specific trial.

Definition at line 114 of file gaze_tracker.cpp.

References std::cerr, std::cout, and std::endl().

114  {
115  if (!this->initialized) {
116  std::cerr << "[GazeTracker] Not initialized (stop_trial())." <<
117  std::endl;
118  return;
119  }
120  std::cout << "[GazeTracker] [Stub] Stopping trial " << this->current_trial_id
121  << std::endl;
122  this->current_trial_id = "";
123 }
ostream cerr
ostream cout
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)

The documentation for this class was generated from the following files: