Permalink
Browse files

Updated SP2 version, started work on readme

  • Loading branch information...
1 parent 82b4c31 commit ca7a6cd10d7184da6a1f36f45456f98e58cfb5be @errollw committed Mar 25, 2014
Showing with 474 additions and 31,432 deletions.
  1. +1 −6 .gitignore
  2. +45 −0 EyeTab.sln
  3. +27 −19 EyeTab/gaze_geometry.cpp
  4. +1 −1 EyeTab/gaze_geometry.h
  5. +2 −0 EyeTab/gaze_smoothing.cpp
  6. +10 −12 EyeTab/gaze_system.cpp
  7. +8 −0 EyeTab/stdafx.cpp
  8. +15 −0 EyeTab/stdafx.h
  9. +8 −0 EyeTab/targetver.h
  10. +100 −602 EyeTab_SP2/EyeTab_SP2.cpp
  11. +0 −4,397 EyeTab_SP2/GetGUID.h
  12. +0 −40 EyeTab_SP2/ReadMe.txt
  13. +0 −150 EyeTab_SP2/comet/array.h
  14. +0 −68 EyeTab_SP2/comet/assert.h
  15. +0 −121 EyeTab_SP2/comet/atl_module.h
  16. +0 −99 EyeTab_SP2/comet/auto_buffer.h
  17. +0 −948 EyeTab_SP2/comet/bstr.h
  18. +0 −628 EyeTab_SP2/comet/calllog.h
  19. +0 −101 EyeTab_SP2/comet/cmd_line_parser.h
  20. +0 −776 EyeTab_SP2/comet/comet.h
  21. +0 −316 EyeTab_SP2/comet/common.h
  22. +0 −243 EyeTab_SP2/comet/config.h
  23. +0 −436 EyeTab_SP2/comet/cp.h
  24. +0 −118 EyeTab_SP2/comet/cptraits.h
  25. +0 −474 EyeTab_SP2/comet/currency.h
  26. +0 −396 EyeTab_SP2/comet/date.h
  27. +0 −1,943 EyeTab_SP2/comet/datetime.h
  28. +0 −675 EyeTab_SP2/comet/dispatch.h
  29. +0 −29 EyeTab_SP2/comet/enum.h
  30. +0 −187 EyeTab_SP2/comet/enum_common.h
  31. +0 −179 EyeTab_SP2/comet/enum_iterator.h
  32. +0 −429 EyeTab_SP2/comet/error.h
  33. +0 −119 EyeTab_SP2/comet/error_fwd.h
  34. +0 −292 EyeTab_SP2/comet/exe_server.h
  35. +0 −1,341 EyeTab_SP2/comet/functor.h
  36. +0 −95 EyeTab_SP2/comet/git.h
  37. +0 −363 EyeTab_SP2/comet/handle.h
  38. +0 −363 EyeTab_SP2/comet/handle_except.h
  39. +0 −546 EyeTab_SP2/comet/impqi.h
  40. +0 −256 EyeTab_SP2/comet/interface.h
  41. +0 −126 EyeTab_SP2/comet/invariant_lock.h
  42. +0 −228 EyeTab_SP2/comet/lw_lock.h
  43. +0 −274 EyeTab_SP2/comet/module.h
  44. +0 −72 EyeTab_SP2/comet/oleidl_comtypes.h
  45. +0 −1,261 EyeTab_SP2/comet/ptr.h
  46. +0 −100 EyeTab_SP2/comet/reference_count.h
  47. +0 −1,302 EyeTab_SP2/comet/registry.h
  48. +0 −65 EyeTab_SP2/comet/regkey.h
  49. +0 −1,498 EyeTab_SP2/comet/safearray.h
  50. +0 −363 EyeTab_SP2/comet/scope_guard.h
  51. +0 −1,588 EyeTab_SP2/comet/server.h
  52. +0 −139 EyeTab_SP2/comet/smart_enum.h
  53. +0 −54 EyeTab_SP2/comet/static_assert.h
  54. +0 −69 EyeTab_SP2/comet/stl.h
  55. +0 −188 EyeTab_SP2/comet/stl_enum.h
  56. +0 −1,566 EyeTab_SP2/comet/stream.h
  57. +0 −228 EyeTab_SP2/comet/threading.h
  58. +0 −451 EyeTab_SP2/comet/tlbinfo.h
  59. +0 −124 EyeTab_SP2/comet/tstring.h
  60. +0 −262 EyeTab_SP2/comet/type_traits.h
  61. +0 −450 EyeTab_SP2/comet/typelist.h
  62. +0 −86 EyeTab_SP2/comet/unittest.h
  63. +0 −125 EyeTab_SP2/comet/util.h
  64. +0 −88 EyeTab_SP2/comet/uuid.h
  65. +0 −441 EyeTab_SP2/comet/uuid_fwd.h
  66. +0 −1,054 EyeTab_SP2/comet/variant.h
  67. +0 −149 EyeTab_SP2/comet/variant_iterator.h
  68. +0 −78 EyeTab_SP2/comet_task_ptr.h
  69. +0 −733 EyeTab_SP2/format.cc
  70. +0 −1,500 EyeTab_SP2/format.h
  71. +8 −0 EyeTab_SP2/stdafx.cpp
  72. +15 −0 EyeTab_SP2/stdafx.h
  73. +8 −0 EyeTab_SP2/targetver.h
  74. +194 −0 EyeTab_SP2/videoInput.h
  75. BIN EyeTab_SP2/videoInput.lib
  76. +32 −2 README.md
View
@@ -17,8 +17,6 @@
*.user
*.sln.docstates
-*.sln
-
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -199,7 +197,4 @@ $RECYCLE.BIN/
# =========================
-stdafx.*
-
-opencv_libs.txt
-targetver.h
+opencv_libs.txt
View
@@ -0,0 +1,45 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EyeTab", "EyeTab\EyeTab.vcxproj", "{6AA5343B-047B-48E2-A839-03D6BDC9D19F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EyeTab_SP2", "EyeTab_SP2\EyeTab_SP2.vcxproj", "{2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|Win32.Build.0 = Debug|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|x64.ActiveCfg = Debug|x64
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Debug|x64.Build.0 = Debug|x64
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|Win32.ActiveCfg = Release|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|Win32.Build.0 = Release|Win32
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|x64.ActiveCfg = Release|x64
+ {6AA5343B-047B-48E2-A839-03D6BDC9D19F}.Release|x64.Build.0 = Release|x64
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Debug|Win32.Build.0 = Debug|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Debug|x64.ActiveCfg = Debug|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|Win32.ActiveCfg = Release|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|Win32.Build.0 = Release|Win32
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|x64.ActiveCfg = Release|x64
+ {2FAAF1F5-56A3-4132-AE61-7FAEB2F1669D}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
@@ -24,7 +24,7 @@ const double FOCAL_LEN_Y_PX = 960.154605354;
const double FOCAL_LEN_Z_PX = (FOCAL_LEN_X_PX + FOCAL_LEN_Y_PX) / 2;
const cv::Point2d PRIN_POINT(634.799023712, 367.91715841);
-vector<Vector3d> ellipse_to_limbus(cv::RotatedRect ellipse){
+vector<Vector3d> ellipse_to_limbus(cv::RotatedRect ellipse, bool limbus_switch=true){
vector<Vector3d> limbus_to_return;
@@ -40,19 +40,12 @@ vector<Vector3d> ellipse_to_limbus(cv::RotatedRect ellipse){
Vector3d limbus_center(iris_x_mm, iris_y_mm, iris_z_mm);
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
+ double tht = acos(min_axis_px / maj_axis_px); // y-axis rotation (radians)
- //Vector3d limb_normal = Vector3d(limbus_center) * -1;
- //limb_normal.normalize();
+ if (limbus_switch) tht = -tht; // ambiguous acos, so sometimes switch limbus
- //AngleAxisd rot1(psi, Vector3d(0,0,1));
- //AngleAxisd rot2(-tht_1, Vector3d(0,1,0));
- //limb_normal = rot1 * limb_normal;
- //limb_normal = rot2 * limb_normal;
-
- // 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));
+ // Get limbus normal for chosen theta
+ Vector3d limb_normal(sin(tht) * cos(psi), -sin(tht) * sin(psi), -cos(tht));
// Now correct for weak perspective by modifying angle by offset between camera axis and limbus
double x_correction = -atan2(iris_y_mm, iris_z_mm);
@@ -78,16 +71,28 @@ Point2d get_gaze_point_mm(Vector3d limb_center, Vector3d limb_normal){
Point2d get_gaze_pt_mm(RotatedRect& ellipse){
- vector<Vector3d> limbus = ellipse_to_limbus(ellipse);
- Point2d p = get_gaze_point_mm(limbus[0], limbus[1]);
+ // get two possible limbus centres and normals because of ambiguous trig
+ vector<Vector3d> limbus_a = ellipse_to_limbus(ellipse, true);
+ vector<Vector3d> limbus_b = ellipse_to_limbus(ellipse, false);
+
+ // calculate gaze points for each possible limbus
+ Point2d gp_mm_a = get_gaze_point_mm(limbus_a[0], limbus_a[1]);
+ Point2d gp_mm_b = get_gaze_point_mm(limbus_b[0], limbus_b[1]);
+
+ // calculate distance from centre of screen for each possible gaze point
+ int dist_a = std::abs(gp_mm_a.x) + std::abs(gp_mm_a.y);
+ int dist_b = std::abs(gp_mm_b.x) + std::abs(gp_mm_b.y);
- return p;
+ // return gaze point closest to screen centre
+ return (dist_a < dist_b) ? gp_mm_a : gp_mm_b;
}
+
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 top left of screen to camera
+
Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm){
int gp_px_x = (gaze_pt_mm.x + CAMERA_OFFSET_MM.x) / SCREEN_SIZE_MM.width * SCREEN_SIZE_PX.width;
@@ -99,12 +104,15 @@ Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm){
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){
+// draws the gaze-points on-screen as circles and crosses
+void show_gaze(Mat& img, vector<Point2i> gaze_pt_raw_s, vector<Scalar> colors_raw, Point2i gaze_pt_smoothed, Scalar color_smoothed){
Mat screen(SCREEN_SIZE_PX.height, SCREEN_SIZE_PX.width, CV_8UC3);
screen.setTo(YELLOW);
- for (int i=0; i<gaze_pt_px_s.size(); i++)
- circle(img, gaze_pt_px_s[i] * scale, 20, colors[i], -1);
+ // draw ra
+ for (int i=0; i<gaze_pt_raw_s.size(); i++)
+ circle(img, gaze_pt_raw_s[i] * scale, 10, colors_raw[i], -1);
+
+ circle(img, gaze_pt_smoothed * scale, 20, color_smoothed, -1);
}
View
@@ -12,4 +12,4 @@ Point2d get_gaze_pt_mm(RotatedRect& ellipse);
Point2i convert_gaze_pt_mm_to_px(Point2d gaze_pt_mm);
-void show_gaze(Mat& img, vector<Point2i> gaze_pt_px_s, vector<Scalar> colors);
+void show_gaze(Mat& img, vector<Point2i> gaze_pt_raw_s, vector<Scalar> colors_raw, Point2i gaze_pt_smoothed, Scalar color_smoothed);
@@ -18,6 +18,7 @@ vector<Point2d> point_history;
vector<float> weights;
float weight_sum = 0;
+// create and initialize weights and history vectors
void gaze_smoothing_init(){
for (float i = 1; i < SMOOTHING_WINDOW_SIZE; i++){
weights.push_back(i);
@@ -26,6 +27,7 @@ void gaze_smoothing_init(){
}
}
+// very simple smoothing low-pass filter
Point2d smooth_gaze(Point2d gaze_point){
Point2d point_to_return(0,0);
View
@@ -120,30 +120,28 @@ void track_gaze(Mat& frame_bgr, Mat& frame_gray) {
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);
- /*Point2d gaze_pt_mm = (get_gaze_pt_mm(ellipse0) + get_gaze_pt_mm(ellipse1)) * 0.5;
+ // smooth gaze point
+ Point2d gaze_pt_mm = (get_gaze_pt_mm(ellipse0) + get_gaze_pt_mm(ellipse1)) * 0.5;
gaze_pt_mm = smooth_gaze(gaze_pt_mm);
Point gaze_pt_px = convert_gaze_pt_mm_to_px(gaze_pt_mm);
- cout << "GAZE PT MM " << gaze_pt_mm.x << " " << gaze_pt_mm.y << endl;
- cout << "GAZE PT PX " << gaze_pt_px.x << " " << gaze_pt_px.y << endl;*/
+ // get raw gaze points also
Point2d gaze_pt_mm_0 = get_gaze_pt_mm(ellipse0);
Point2d gaze_pt_mm_1 = get_gaze_pt_mm(ellipse1);
Point2i gaze_pt_px_0 = convert_gaze_pt_mm_to_px(gaze_pt_mm_0);
Point2i gaze_pt_px_1 = convert_gaze_pt_mm_to_px(gaze_pt_mm_1);
- cout << "GAZE PT 1 " << gaze_pt_mm_0 << " " << gaze_pt_px_0 << endl;
- cout << "GAZE PT 2 " << gaze_pt_mm_1 << " " << gaze_pt_px_1 << endl;
+ // *** DEBUG DRAWING ***
+ // draw raw and smoothed gaze points
vector<Point2i> gp_px_s;
gp_px_s.push_back(gaze_pt_px_0);
gp_px_s.push_back(gaze_pt_px_1);
- vector<Scalar> colors;
- colors.push_back(RED);
- colors.push_back(BLUE);
-
- show_gaze(frame_bgr, gp_px_s, colors);
-
- // *** DEBUG DRAWING ***
+ gp_px_s.push_back(gaze_pt_px);
+ vector<Scalar> colors_raw;
+ colors_raw.push_back(RED);
+ colors_raw.push_back(BLUE);
+ show_gaze(frame_bgr, gp_px_s, colors_raw, gaze_pt_px, YELLOW);
// DEBUG DRAWING - coarse ROIs
rectangle(frame_bgr, eye0_roi, GREEN);
View
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// EyeTab.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
View
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
View
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
Oops, something went wrong.

0 comments on commit ca7a6cd

Please sign in to comment.