Skip to content

Commit

Permalink
eye gaze ver 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aravind-Suresh committed Jul 2, 2015
0 parents commit 9a310b6
Show file tree
Hide file tree
Showing 1,238 changed files with 449,196 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Makefile for Project Timeline
#
# Your compiler
CXX = g++

# Compilation flags
# '-g' turns debugging flags on.
# Not Using O2 flag for optimisation.
CXXFLAGS = -g -I./include -I./src/dlib/all/source.cpp -ljpeg -mavx -lm -lpthread -lX11 -DDLIB_HAVE_BLAS -DNDEBUG -DDLIB_JPEG_SUPPORT -DDLIB_HAVE_AVX -O3 `pkg-config --cflags opencv`

# Linker flags
# When you need to add a library
LDFLAGS = -ljpeg -mavx -lm -lpthread -lX11 `pkg-config --libs opencv` -DDLIB_HAVE_BLAS -DNDEBUG -DDLIB_JPEG_SUPPORT -DDLIB_HAVE_AVX -O3

# all is a target
# $(VAR) gives value of the variable.
# $@ stores the target
# $^ stores the dependency
all: bin/oic

bin/oic: obj/dlib.o obj/faceDetection.o obj/pupilDetection.o obj/kalmanFilters.o obj/util.o obj/oic.o
$(CXX) -o $@ $^ $(LDFLAGS)

obj/dlib.o: src/dlib/all/source.cpp
mkdir -p obj bin
$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/faceDetection.o: src/faceDetection.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/pupilDetection.o: src/pupilDetection.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/kalmanFilters.o: src/kalmanFilters.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/util.o: src/util.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/oic.o: src/oic.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<

# .PHONY tells make that 'all' or 'clean' aren't _actually_ files, and always
# execute the compilation action when 'make all' or 'make clean' are used
.PHONY: all oic

# Delete all the temporary files we've created so far
clean:
rm -rf obj/*.o
rm -rf bin/oic
Binary file added bin/oic
Binary file not shown.
8 changes: 8 additions & 0 deletions include/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H

double PI = 3.141592653589;
double Rn = 0.5;
double Rm = 0.5;

#endif
50 changes: 50 additions & 0 deletions include/faceDetection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef FACE_ANALYSIS_H
#define FACE_ANALYSIS_H

struct FaceFeatures {
cv::Point face_centre;

cv::Point left_eye;
cv::Point right_eye;
cv::Point mid_eye;

cv::Point nose_base;
cv::Point nose_tip;

cv::Point mouth;

void assign(cv::Point c_face_centre, cv::Point c_left_eye, cv::Point c_right_eye, cv::Point c_nose_tip, cv::Point c_mouth);
};

struct FaceData {
double left_eye_nose_distance;
double right_eye_nose_distance;
double left_eye_right_eye_distance;
double nose_mouth_distance;

double mid_eye_mouth_distance; //Lf
double nose_base_nose_tip_distance; //Ln

void assign(FaceFeatures* f);
};

struct FacePose {
double theta, tau;
double sigma, symm_x;

double normal[3]; //Vector for storing Facial normal

double yaw, pitch;

double kalman_pitch, kalman_yaw;
double kalman_pitch_pre, kalman_yaw_pre;

void assign(FaceFeatures* f, FaceData* d);
};

void draw_facial_normal(cv::Mat& img, dlib::full_object_detection shape, std::vector<double> normal);
void draw_crosshair(cv::Mat img, CvPoint centre, int circle_radius, int line_radius);
void project_facial_pose(cv::Mat img, double normal[3], double sigma, double theta);
double find_sigma(int ln, int lf, double Rn, double theta);

#endif
34 changes: 34 additions & 0 deletions include/kalmanFilters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef KALMAN_FILTERS_H
#define KALMAN_FILTERS_H

void init_kalman_point_p_l(cv::Point pt_pos_l);
cv::Point2f kalman_correct_point_p_l(cv::Point pt_pos_l, cv::Point pt_pos_l_old, cv::Point pt_vel_old);

void init_kalman_point_p_r(cv::Point pt_pos_r);
cv::Point2f kalman_correct_point_p_r(cv::Point pt_pos_r, cv::Point pt_pos_r_old, cv::Point pt_vel_old);

void init_kalman_point_e_l(cv::Point pt_pos_l);
cv::Point2f kalman_correct_point_e_l(cv::Point pt_pos_l, cv::Point pt_pos_l_old);

void init_kalman_point_e_r(cv::Point pt_pos_r);
cv::Point2f kalman_correct_point_e_r(cv::Point pt_pos_r, cv::Point pt_pos_r_old);

void init_kalman_ce_l(std::vector<double> vec);
void kalman_predict_correct_ce_l(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

void init_kalman_ce_r(std::vector<double> vec);
void kalman_predict_correct_ce_r(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

void init_kalman_ep_l(std::vector<double> vec);
void kalman_predict_correct_ep_l(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

void init_kalman_ep_r(std::vector<double> vec);
void kalman_predict_correct_ep_r(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

void init_kalman_cp_l(std::vector<double> vec);
void kalman_predict_correct_cp_l(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

void init_kalman_cp_r(std::vector<double> vec);
void kalman_predict_correct_cp_r(std::vector<double> vec, std::vector<double> old, std::vector<double>& vec_pred);

#endif
18 changes: 18 additions & 0 deletions include/pupilDetection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef PUPIL_DETECTION_H
#define PUPIL_DETECTION_H

cv::Point unscale_point(cv::Point p, cv::Rect origSize);
void scale_standard_size(const cv::Mat &src,cv::Mat &dst);
cv::Mat compute_x_gradient(const cv::Mat &mat);
double compute_threshold(const cv::Mat &mat, double stdDevFactor);
cv::Mat get_matrix_magnitude(const cv::Mat &matX, const cv::Mat &matY);
bool check_point_in_mat(cv::Point p,int rows,int cols);
bool is_point_in_mat(const cv::Point &np, const cv::Mat &mat);
cv::Mat remove_edges(cv::Mat &mat);
void check_pupil(int x, int y, const cv::Mat &weight,double gx, double gy, cv::Mat &out);
cv::Point get_pupil_coordinates(cv::Mat eye_mat,cv::Rect eye);
void draw_eye_gaze(cv::Point pt, std::vector<double> vec_gaze, cv::Rect roi_eye, cv::Mat& img);
double get_z_component(double Cf_left, cv::Point pt_p_kalman, cv::Point pt_e_kalman, std::vector<double> vec_ce_kalman);
void retrace_eye_center(cv::Point& pt_e_pos, double normal[3], double mag);

#endif
17 changes: 17 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef UTIL_H
#define UTIL_H

void blow_up_rect(cv::Rect& rect, double f);
void show_images(int e ,int l, int h, std::vector<cv::Mat> imgs);
double get_distance(cv::Point p1, cv::Point p2);
cv::Point get_mid_point(cv::Point p1, cv::Point p2);
double get_vector_magnitude(double vec[], int size);
void compute_vector_sum(std::vector<double> vec1, std::vector<double> vec2, std::vector<double>& vec_sum);
double get_angle_between(cv::Point pt1, cv::Point pt2);
void make_unit_vector(std::vector<double> vec, std::vector<double>& unit_vector);
double scalar_product(std::vector<double> vec1, std::vector<double> vec2);
cv::Mat get_rotation_matrix_z(double theta);
void get_rotated_vector(std::vector<double> vec, std::vector<double>& vec_rot);
void get_reverse_vector(std::vector<double> vec, std::vector<double>& vec_rot);

#endif
Binary file added obj/dlib.o
Binary file not shown.
Binary file added obj/faceDetection.o
Binary file not shown.
Binary file added obj/kalmanFilters.o
Binary file not shown.
Binary file added obj/oic.o
Binary file not shown.
Binary file added obj/pupilDetection.o
Binary file not shown.
Binary file added obj/util.o
Binary file not shown.
Binary file added res/shape_predictor_68_face_landmarks.dat
Binary file not shown.
6 changes: 6 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all:
oic
oic:

g++ -lX11 ./dlib/all/source.cpp oic.cpp faceDetection.cpp kalmanFilters.cpp util.cpp pupilDetection.cpp -o oic -ljpeg -mavx `pkg-config --cflags --libs opencv`

5 changes: 5 additions & 0 deletions src/Makefile~
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
oic

g++ -lX11 ./dlib/all/source.cpp oic.cpp faceDetection.cpp kalmanFilters.cpp util.cpp pupilDetection.cpp -o oic -ljpeg -mavx `pkg-config --cflags --libs opencv`

8 changes: 8 additions & 0 deletions src/constants.h~
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H

double PI = 3.141592653589;
double Rn = 0.5;
double Rm = 0.5;

#endif
Loading

0 comments on commit 9a310b6

Please sign in to comment.