Permalink
Browse files

Comments

And removing unused code
  • Loading branch information...
1 parent ec6b3bc commit 7ec7aecdbb003538bba66bcaf5a43d8772d74ba8 @errollw committed Feb 25, 2014
Showing with 11 additions and 12 deletions.
  1. +2 −1 EyeTab/EyeTab.cpp
  2. +3 −1 EyeTab/fit_ellipse.cpp
  3. +6 −10 EyeTab/gaze_geometry.cpp
View
@@ -59,9 +59,10 @@ int main(int argc, const char** argv)
putText(captureFrame, fps_string, Point2i(11, 21), FONT_HERSHEY_SIMPLEX, 0.5, BLACK);
putText(captureFrame, fps_string, Point2i(10, 20), FONT_HERSHEY_SIMPLEX, 0.5, WHITE);
- // Show the output
+ // show the output
imshow("output", captureFrame);
+ // check input for taking screenshots or quitting
switch (waitKey(1)){
case 's':
screenshot_filename = "SS_" + to_string(num_screenshots++);
View
@@ -7,13 +7,15 @@
#include <iostream>
#include <stdio.h>
-#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
+#include <time.h>
#include "ConicSection.h"
#include "utils.h"
using namespace std;
+// adapted from https://bitbucket.org/Leszek/pupil-tracker/ - Lech Swirski
+// robustly fit ellipse to potential limbus points with RANSAC
cv::RotatedRect fit_ellipse(std::vector<cv::Point2f> edgePoints, cv::Mat_<float> mPupilSobelX, cv::Mat_<float> mPupilSobelY){
// Number of points needed for a model
View
@@ -42,8 +42,6 @@ vector<Vector3d> ellipse_to_limbus(cv::RotatedRect ellipse){
double psi = CV_PI / 180.0 * (ellipse.angle+90); // z-axis rotation (radians)
double tht_1 = acos(min_axis_px / maj_axis_px); // y-axis rotation (radians)
double tht_2 = -tht_1; // as acos has 2 ambiguous solutions
-
- cout << "ANGLE " << ellipse.angle << endl;
//Vector3d limb_normal = Vector3d(limbus_center) * -1;
//limb_normal.normalize();
@@ -64,22 +62,20 @@ vector<Vector3d> ellipse_to_limbus(cv::RotatedRect ellipse){
limb_normal = rot1 * limb_normal;
limb_normal = rot2 * limb_normal;
- cout << "LIMBUS CENTER " << limbus_center.x() << " " << limbus_center.y() << " " << limbus_center.z() << endl;
- cout << "LIMBUS NORMAL " << limb_normal.x() << " " << limb_normal.y() << " " << limb_normal.z() << endl;
-
limbus_to_return.push_back(limbus_center);
limbus_to_return.push_back(limb_normal);
return limbus_to_return;
}
-// Returns intersection with z-plane of optical axis vector (mm)
+// returns intersection with z-plane of optical axis vector (mm)
Point2d get_gaze_point_mm(Vector3d limb_center, Vector3d limb_normal){
// ray/plane intersection
double t = -limb_center.z() / limb_normal.z();
return Point2d(limb_center.x() + limb_normal.x() * t, limb_center.y() + limb_normal.y() * t);
}
+
Point2d get_gaze_pt_mm(RotatedRect& ellipse){
vector<Vector3d> limbus = ellipse_to_limbus(ellipse);
@@ -89,8 +85,8 @@ Point2d get_gaze_pt_mm(RotatedRect& ellipse){
}
const Size SCREEN_SIZE_MM(236, 134);
-const Size SCREEN_SIZE_PX(1920, 1080); // Screen size in pixels
-const Point2i CAMERA_OFFSET_MM(120, 140); // Vector from camera to top left of screen
+const Size SCREEN_SIZE_PX(1920, 1080); // screen size in pixels
+const Point2i CAMERA_OFFSET_MM(120, 140); // vector from top left of screen to camera
Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm){
@@ -100,11 +96,11 @@ Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm){
return Point2i(gp_px_x, gp_px_y);
}
-// Draws the gaze-point on-screen
+
float scale = 720 / float(SCREEN_SIZE_PX.height);
+// Draws the gaze-point on-screen
void show_gaze(Mat& img, vector<Point2i> gaze_pt_px_s, vector<Scalar> colors){
- //resizeWindow("Gaze Output", SCREEN_SIZE_PX.width, SCREEN_SIZE_PX.height);
Mat screen(SCREEN_SIZE_PX.height, SCREEN_SIZE_PX.width, CV_8UC3);
screen.setTo(YELLOW);

0 comments on commit 7ec7aec

Please sign in to comment.