From 236fcd70dd65ed8b620befd67846a9aabae84c45 Mon Sep 17 00:00:00 2001 From: errollw Date: Tue, 25 Feb 2014 12:37:42 +0000 Subject: [PATCH] Removing unnecessary code --- EyeTab/EyeTab.cpp | 37 +++++++++++++------------------------ EyeTab/gaze_geometry.cpp | 6 +++--- EyeTab/gaze_smoothing.cpp | 2 +- EyeTab/gaze_smoothing.h | 2 +- EyeTab/gaze_system.cpp | 2 +- 5 files changed, 19 insertions(+), 30 deletions(-) diff --git a/EyeTab/EyeTab.cpp b/EyeTab/EyeTab.cpp index c6c0d4f..df207c6 100644 --- a/EyeTab/EyeTab.cpp +++ b/EyeTab/EyeTab.cpp @@ -6,8 +6,8 @@ #include #include -#include /* clock_t, clock, CLOCKS_PER_SEC */ -#include /* floor */ +#include +#include #include "eye_center.h" #include "erase_specular.h" @@ -26,55 +26,44 @@ String screenshot_filename; int main(int argc, const char** argv) { - // init modules + // initialize modules lin_polar_init(); gaze_system_init(); - //init_gaze_smoothing(); + gaze_smoothing_init(); - //setup video capture device + // start reading in camera frames (720p video) VideoCapture cap("videos\\sample_video.mp4"); - // VideoCapture cap("C:\\Users\\Erroll\\Documents\\Part 3 Project (local)\\Gaze Data\\P03\\P03_L1_D1_20130517_163141.mp4"); - // VideoCapture cap("C:\\Users\\Erroll\\Documents\\Part 3 Project (local)\\Gaze Data\\P06\\P06_L1_D1_20130520_154535.mp4"); - - int cam_idx = argc > 1 ? atoi(argv[1]) : 0; - //VideoCapture cap(CV_CAP_DSHOW + 0); - cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280); - cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720); - //setup image files used in the capture process + // setup image files used in the capture process Mat captureFrame, grayscaleFrame, smallFrame; - //create a window to present the results - namedWindow("outputCapture", 1); - //namedWindow("Gaze Output", 1); - //moveWindow("Gaze Output", 0, 0); + // create a window to present the results + namedWindow("output", 1); - //create a loop to capture and find eye-pairs + // main loop while(true) { clock_t start = clock(); - //capture a new image frame + // read in a new image frame cap >> captureFrame; // captureFrame = imread("images\\SS_0.jpg", CV_LOAD_IMAGE_COLOR); - // flip(captureFrame,captureFrame,1); - //if (rot_180) flip(captureFrame, captureFrame, -1); - //convert captured image to gray scale and equalize + // convert captured image to equalized gray scale cvtColor(captureFrame, grayscaleFrame, CV_BGR2GRAY); equalizeHist(grayscaleFrame, grayscaleFrame); track_gaze(captureFrame, grayscaleFrame); - // Show calculated FPS + // show calculated FPS (two draw functions to simulate text shadow) String fps_string = to_string(int(1 / ( ((float)clock()-start) / CLOCKS_PER_SEC ))) + " FPS"; 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 - imshow("outputCapture", captureFrame); + imshow("output", captureFrame); switch (waitKey(5)){ case 's': diff --git a/EyeTab/gaze_geometry.cpp b/EyeTab/gaze_geometry.cpp index 0e3dbf2..f8dc49c 100644 --- a/EyeTab/gaze_geometry.cpp +++ b/EyeTab/gaze_geometry.cpp @@ -53,7 +53,7 @@ vector ellipse_to_limbus(cv::RotatedRect ellipse){ //limb_normal = rot1 * limb_normal; //limb_normal = rot2 * limb_normal; - // Ignore other possible normal - found in practise to be wrong in general + // Ignore other possible normal - wrong in general as will point the wrong direction Vector3d limb_normal(sin(tht_1) * cos(psi), -sin(tht_1) * sin(psi), -cos(tht_1)); // Now correct for weak perspective by modifying angle by offset between camera axis and limbus @@ -88,9 +88,9 @@ Point2d get_gaze_pt_mm(RotatedRect& ellipse){ return p; } -const Size SCREEN_SIZE_MM(256,144); +const Size SCREEN_SIZE_MM(236, 134); const Size SCREEN_SIZE_PX(1920, 1080); // Screen size in pixels -const Point2i CAMERA_OFFSET_MM(128, 155); // Vector from camera to top left of screen +const Point2i CAMERA_OFFSET_MM(120, 140); // Vector from camera to top left of screen Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm){ diff --git a/EyeTab/gaze_smoothing.cpp b/EyeTab/gaze_smoothing.cpp index 8504e93..4007f2a 100644 --- a/EyeTab/gaze_smoothing.cpp +++ b/EyeTab/gaze_smoothing.cpp @@ -18,7 +18,7 @@ vector point_history; vector weights; float weight_sum = 0; -void init_gaze_smoothing(){ +void gaze_smoothing_init(){ for (float i = 1; i < SMOOTHING_WINDOW_SIZE; i++){ weights.push_back(i); weight_sum += i; diff --git a/EyeTab/gaze_smoothing.h b/EyeTab/gaze_smoothing.h index 57fb465..d9ea7ae 100644 --- a/EyeTab/gaze_smoothing.h +++ b/EyeTab/gaze_smoothing.h @@ -1,6 +1,6 @@ using namespace std; using namespace cv; -void init_gaze_smoothing(); +void gaze_smoothing_init(); Point2d smooth_gaze(Point2d gaze_point); \ No newline at end of file diff --git a/EyeTab/gaze_system.cpp b/EyeTab/gaze_system.cpp index e4dfbbf..3b7fecd 100644 --- a/EyeTab/gaze_system.cpp +++ b/EyeTab/gaze_system.cpp @@ -116,7 +116,7 @@ void track_gaze(Mat& frame_bgr, Mat& frame_gray) { Sobel(frame_gray(eye1_roi_ref), grad_y, CV_32F, 0, 1, 5); RotatedRect ellipse1 = fit_ellipse(poss_limb_pts_1, grad_x, grad_y); - // Shift ellipses fit + // Shift ellipses fit by their ROI offset ellipse0 = RotatedRect(Point2i(ellipse0.center) + eye0_roi_ref.tl(), ellipse0.size, ellipse0.angle); ellipse1 = RotatedRect(Point2i(ellipse1.center) + eye1_roi_ref.tl(), ellipse1.size, ellipse1.angle);