Permalink
Browse files

Initial commit of EyeTab files

1 parent c27fa65 commit 613aa777e4a9a9402a421142bab53a938551fd00 @errollw committed Jan 8, 2014
View
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
View
@@ -11,3 +11,192 @@
*.lai
*.la
*.a
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+*.sln
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+build/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+#NUNIT
+*.VisualState.xml
+TestResult.xml
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+_NCrunch_*
+.*crunch*.local.xml
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+#packages/*
+## TODO: If the tool you use requires repositories.config, also uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
+# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
+!packages/build/
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# VS proj
+*.vcxproj
+*.vcxproj.filters
+
+# =========================
+# Windows detritus
+# =========================
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# =========================
+
+opencv_libs.txt
View
@@ -0,0 +1,75 @@
+#ifndef __CONIC_SECTION_H__
+#define __CONIC_SECTION_H__
+
+// From http://www.cl.cam.ac.uk/research/rainbow/projects/pupiltracking/
+
+template<typename T>
+class ConicSection_
+{
+public:
+ T A,B,C,D,E,F;
+
+ ConicSection_(cv::RotatedRect r)
+ {
+ cv::Point_<T> axis((T)std::cos(CV_PI/180.0 * r.angle), (T)std::sin(CV_PI/180.0 * r.angle));
+ cv::Point_<T> centre(r.center);
+ T a = r.size.width/2;
+ T b = r.size.height/2;
+
+ initFromEllipse(axis, centre, a, b);
+ }
+
+ T algebraicDistance(cv::Point_<T> p)
+ {
+ return A*p.x*p.x + B*p.x*p.y + C*p.y*p.y + D*p.x + E*p.y + F;
+ }
+
+ T distance(cv::Point_<T> p)
+ {
+ // dist
+ // -----------
+ // |grad|^0.45
+
+ T dist = algebraicDistance(p);
+ cv::Point_<T> grad = algebraicGradient(p);
+
+ T sqgrad = grad.dot(grad);
+
+ return dist / std::pow(sqgrad, T(0.45/2));
+ }
+
+ cv::Point_<T> algebraicGradient(cv::Point_<T> p)
+ {
+ return cv::Point_<T>(2*A*p.x + B*p.y + D, B*p.x + 2*C*p.y + E);
+ }
+
+ cv::Point_<T> algebraicGradientDir(cv::Point_<T> p)
+ {
+ cv::Point_<T> grad = algebraicGradient(p);
+ T len = std::sqrt(grad.ddot(grad));
+ grad.x /= len;
+ grad.y /= len;
+ return grad;
+ }
+
+protected:
+ void initFromEllipse(cv::Point_<T> axis, cv::Point_<T> centre, T a, T b)
+ {
+ T a2 = a * a;
+ T b2 = b * b;
+
+ A = axis.x*axis.x / a2 + axis.y*axis.y / b2;
+ B = 2*axis.x*axis.y / a2 - 2*axis.x*axis.y / b2;
+ C = axis.y*axis.y / a2 + axis.x*axis.x / b2;
+ D = (-2*axis.x*axis.y*centre.y - 2*axis.x*axis.x*centre.x) / a2
+ + (2*axis.x*axis.y*centre.y - 2*axis.y*axis.y*centre.x) / b2;
+ E = (-2*axis.x*axis.y*centre.x - 2*axis.y*axis.y*centre.y) / a2
+ + (2*axis.x*axis.y*centre.x - 2*axis.x*axis.x*centre.y) / b2;
+ F = (2*axis.x*axis.y*centre.x*centre.y + axis.x*axis.x*centre.x*centre.x + axis.y*axis.y*centre.y*centre.y) / a2
+ + (-2*axis.x*axis.y*centre.x*centre.y + axis.y*axis.y*centre.x*centre.x + axis.x*axis.x*centre.y*centre.y) / b2
+ - 1;
+ }
+};
+typedef ConicSection_<float> ConicSection;
+
+#endif // __CONIC_SECTION_H__
View
@@ -0,0 +1,91 @@
+#include "stdafx.h"
+
+#include <opencv2/objdetect/objdetect.hpp>
+#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+
+#include <iostream>
+#include <stdio.h>
+#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
+#include <math.h> /* floor */
+
+#include "eye_center.h"
+#include "erase_specular.h"
+#include "get_poss_limb_pts.h"
+#include "fit_ellipse.h"
+#include "utils.h"
+#include "get_eyelids.h"
+#include "gaze_system.h"
+#include "gaze_smoothing.h"
+
+using namespace std;
+using namespace cv;
+
+int num_screenshots = 0;
+String screenshot_filename;
+
+int main(int argc, const char** argv)
+{
+ // init modules
+ lin_polar_init();
+ gaze_system_init();
+ //init_gaze_smoothing();
+
+ //setup video capture device
+ // VideoCapture cap("C:\\Users\\Erroll\\Documents\\Part 3 Project (local)\\Gaze Data\\P01\\P01_L2_D1_20130517_133459.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(cam_idx);
+ cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
+ cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720);
+
+ bool rot_180 = argc > 2 ? true : false;
+
+ //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 loop to capture and find eye-pairs
+ while(true)
+ {
+ clock_t start = clock();
+
+ //capture 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
+ cvtColor(captureFrame, grayscaleFrame, CV_BGR2GRAY);
+ equalizeHist(grayscaleFrame, grayscaleFrame);
+
+ track_gaze(captureFrame, grayscaleFrame);
+
+ // Show calculated FPS
+ 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);
+
+ switch (waitKey(5)){
+ case 's':
+ screenshot_filename = "SS_" + to_string(num_screenshots++);
+ imwrite(screenshot_filename + ".jpg", captureFrame);
+ break;
+ case 'q': return 0;
+ }
+ }
+
+ return 0;
+}
Oops, something went wrong.

0 comments on commit 613aa77

Please sign in to comment.