diff --git a/EyeTab/EyeTab.cpp b/EyeTab/EyeTab.cpp index db51180..fbe87cb 100644 --- a/EyeTab/EyeTab.cpp +++ b/EyeTab/EyeTab.cpp @@ -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++); diff --git a/EyeTab/fit_ellipse.cpp b/EyeTab/fit_ellipse.cpp index fa71405..4a01810 100644 --- a/EyeTab/fit_ellipse.cpp +++ b/EyeTab/fit_ellipse.cpp @@ -7,13 +7,15 @@ #include #include -#include /* clock_t, clock, CLOCKS_PER_SEC */ +#include #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 edgePoints, cv::Mat_ mPupilSobelX, cv::Mat_ mPupilSobelY){ // Number of points needed for a model diff --git a/EyeTab/gaze_geometry.cpp b/EyeTab/gaze_geometry.cpp index f8dc49c..5d51767 100644 --- a/EyeTab/gaze_geometry.cpp +++ b/EyeTab/gaze_geometry.cpp @@ -42,8 +42,6 @@ vector 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,15 +62,12 @@ vector 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 @@ -80,6 +75,7 @@ Point2d get_gaze_point_mm(Vector3d limb_center, Vector3d limb_normal){ return Point2d(limb_center.x() + limb_normal.x() * t, limb_center.y() + limb_normal.y() * t); } + Point2d get_gaze_pt_mm(RotatedRect& ellipse){ vector 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 gaze_pt_px_s, vector 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);