forked from iitmcvg/eye-gaze
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added gesture creation. added gesture listen. created more gestures.
- Loading branch information
1 parent
9a08809
commit 0832f04
Showing
10 changed files
with
160 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-0.08628 -0.143821 -0.985835 | ||
-0.0879976 -0.175979 -0.980453 | ||
-0.121439 -0.151811 -0.980921 | ||
-0.126898 -0.190397 -0.973471 | ||
-0.162617 -0.162563 -0.973206 | ||
-0.151878 -0.121492 -0.980904 | ||
-0.151681 -0.121334 -0.980954 | ||
-0.127055 -0.0317673 -0.991387 | ||
-7.65805e-14 -0.0643828 -0.997925 | ||
-0.0288098 -0.0576145 -0.997923 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-0.0975447 -0.130089 -0.986692 | ||
-0.130573 -0.0979078 -0.986592 | ||
-0.130518 -0.0978662 -0.986604 | ||
-0.127166 -0.031795 -0.991372 | ||
-0.0525942 0.0262994 -0.99827 | ||
-0.111594 0.111556 -0.987473 | ||
-0.0779051 0.0519232 -0.995608 | ||
-0.0917627 -0.0305942 -0.995311 | ||
-0.0880408 -0.176066 -0.980433 | ||
-0.129177 -0.193816 -0.972496 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-0.126983 1.00731e-13 -0.991905 | ||
-0.0903152 0.0301116 -0.995458 | ||
-0.0903152 0.0301116 -0.995458 | ||
-0.0903152 0.0301116 -0.995458 | ||
-0.0567651 0.0283851 -0.997984 | ||
0.0889263 0.0296485 -0.995597 | ||
0.0902386 -0.0300861 -0.995466 | ||
-0.0888819 0.0296337 -0.995601 | ||
-0.124999 9.91575e-14 -0.992157 | ||
-0.126983 1.00731e-13 -0.991905 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include <math.h> | ||
#include <stdlib.h> | ||
#include <string> | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
#include <opencv2/highgui/highgui.hpp> | ||
#include <opencv2/opencv.hpp> | ||
#include <opencv2/legacy/compat.hpp> | ||
|
||
#include "dlib/opencv.h" | ||
#include "dlib/image_processing/frontal_face_detector.h" | ||
#include "dlib/image_processing/render_face_detections.h" | ||
#include "dlib/gui_widgets.h" | ||
|
||
#include "faceDetection.h" | ||
#include "util.h" | ||
#include "gestureDetection.h" | ||
|
||
int main(int argc, char **argv) { | ||
|
||
cv::VideoCapture cap(0); | ||
|
||
FaceFeatures *face_features = new FaceFeatures(); | ||
FaceData *face_data = new FaceData(); | ||
FacePose *face_pose = new FacePose(); | ||
FaceGesture *face_gesture = new FaceGesture(); | ||
|
||
face_gesture->assign(15); | ||
|
||
cv::Mat frame, frame_clr; | ||
|
||
dlib::frontal_face_detector detector = dlib::get_frontal_face_detector(); | ||
dlib::shape_predictor pose_model; | ||
|
||
dlib::deserialize("./res/shape_predictor_68_face_landmarks.dat") >> pose_model; | ||
|
||
std::vector<std::vector<std::vector<double> > > gestures_learned(5); | ||
|
||
read_vector_from_file("left2right_fast.txt", gestures_learned[0]); | ||
read_vector_from_file("left_rock.txt", gestures_learned[1]); | ||
read_vector_from_file("nod.txt", gestures_learned[2]); | ||
read_vector_from_file("right_rock.txt", gestures_learned[3]); | ||
read_vector_from_file("up2down_fast.txt", gestures_learned[4]); | ||
|
||
int score_temp_1, score_temp_2, pos; | ||
std::vector<double> vec_normal(3); | ||
std::vector<std::vector<double> > vec_current_bin(0); | ||
|
||
while(1) { | ||
try { | ||
cap>>frame; | ||
cv::flip(frame, frame, 1); | ||
frame.copyTo(frame_clr); | ||
cv::cvtColor(frame, frame, CV_BGR2GRAY); | ||
|
||
dlib::cv_image<unsigned char> cimg_gray(frame); | ||
dlib::cv_image<dlib::bgr_pixel> cimg_clr(frame_clr); | ||
|
||
std::vector<dlib::rectangle> faces = detector(cimg_gray); | ||
|
||
std::vector<dlib::full_object_detection> shapes; | ||
for (unsigned long i = 0; i < faces.size(); ++i) | ||
shapes.push_back(pose_model(cimg_gray, faces[i])); | ||
|
||
if(faces.size()) { | ||
|
||
dlib::full_object_detection shape = shapes[0]; | ||
|
||
face_features->assign(cv::Point(0,0), | ||
get_mid_point(cv::Point(shape.part(42).x(), shape.part(42).y()), | ||
cv::Point(shape.part(45).x(), shape.part(45).y())), | ||
get_mid_point(cv::Point(shape.part(36).x(), shape.part(36).y()), | ||
cv::Point(shape.part(39).x(), shape.part(39).y())), | ||
cv::Point(shape.part(30).x(), shape.part(30).y()), | ||
get_mid_point(cv::Point(shape.part(48).x(), shape.part(48).y()), | ||
cv::Point(shape.part(54).x(), shape.part(54).y()))); | ||
|
||
face_data->assign(face_features); | ||
|
||
face_pose->assign(face_features, face_data); | ||
|
||
std::cout<<face_pose->normal[0]<<" "<<face_pose->normal[1]<<" "<<face_pose->normal[2]<<"\n"; | ||
|
||
vec_normal[0] = face_pose->normal[0]; | ||
vec_normal[1] = face_pose->normal[1]; | ||
vec_normal[2] = face_pose->normal[2]; | ||
|
||
face_gesture->normal->push(vec_normal); | ||
//std::cout<<"Filled : "<<face_gesture->normal->get_filled()<<std::endl; | ||
|
||
vec_current_bin = face_gesture->normal->clone(); | ||
//std::cout<<"Size : "<<vec_current_bin.size()<<std::endl; | ||
|
||
score_temp_1 = DTWScore(vec_current_bin, gestures_learned[0]); | ||
pos = 0; | ||
|
||
for(int i=1;i<gestures_learned.size();i++) { | ||
score_temp_2 = DTWScore(vec_current_bin, gestures_learned[i]); | ||
std::cout<<score_temp_2<<" "; | ||
if(score_temp_2 < score_temp_1) { | ||
score_temp_1 = score_temp_2; | ||
pos = i; | ||
} | ||
} | ||
|
||
std::cout<<"Matched with gesture["<<pos<<"]"<<std::endl; | ||
} | ||
else { | ||
std::cout<<"Zero faces"<<std::endl; | ||
} | ||
} | ||
catch(std::exception& e) { | ||
std::cout<<e.what()<<std::endl; | ||
break; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters