资源简介
在VS2012上基于opencv的C++人眼识别与眨眼检测源代码
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “constants.h“
#include “opencv2/opencv.hpp“
using namespace cv;
using namespace std;
/* Global variables */
//Mat prevgray; // first attempt
Mat previousFace;
Mat currentFace;
bool leftEyeOpen = true;
bool rightEyeOpen = true;
int calibrationFace = calibrationDefault;
int blinkNumberLeft = 0;
int blinkNumberRight = 0;
clock_t leftEyeCloseTime;
clock_t rightEyeCloseTime;
/* Functions */
//void findEyes(Mat matCapturedGrayImage Mat matCapturedImage CascadeClassifier cascEye CascadeClassifier cascFace); // first attempt
//void drawOptFlowMap(const Mat& flow Mat& cflowmap int step double scale const Scalar& color); // first attempt
void headTracing(Mat matCapturedGrayImage Mat matCapturedImage CascadeClassifier cascEye CascadeClassifier cascFace Rect &detectedFaceRegion);
void calcFlow(const Mat& flow Mat& cflowmap double scale int &globalMovementX int &globalMovementY);
Rect findBiggestFace(Mat matCapturedGrayImage CascadeClassifier cascFace);
void eyeTracking(Mat &matCurrentEye Mat &matPreviousEye);
void getEyesFromFace(Mat &matFace Mat &matLeftEye Mat &matRightEye);
void detectblink(Mat &matEyePrevious Mat &matEyeCurrent String eye bool &eyeOpen int &blinkNumber clock_t &closeTime);
/************************************************************************** to_string_with_precision **************************************************************************/
template
///From (for example double) value makes string with just whole numbers
std::string to_string_with_precision(const T a_value const int n = 6)
{
std::ostringstream out;
out << std::setprecision(n) << a_value;
return out.str();
}
/************************************************************************** main **************************************************************************/
/// Application will detect eye blinking by calculating optical flow of face and eyes
int main()
{
CascadeClassifier cascFace cascEye;
if (!cascFace.load(frontalFacePath)) {
printf(“Error loading cascade file for face“);
return 1;
}
if (!cascEye.load(eyePath)) {
printf(“Error loading cascade file for eye“);
return 1;
}
Rect detectedFaceRegion; // have to be created here; if it was inside while the image would be still changing
cout << “\n\tESC - turn this program off\n\tf - recalibrate face\n\tc - reset counter\n\n“;
namedWindow(“Result“ CV_WINDOW_NORMAL);
VideoCapture capture(0);
if (!capture.isOpened())
{
printf(“error to initialize camera“);
return 1;
}
Mat matCapturedImage;
while (1)
{
Mat matCapturedGrayImage;
capture >> matC
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 881 2015-06-05 06:13 TiredTracker-master\OPENCV_DEBUG.props
....... 892 2015-06-05 06:13 TiredTracker-master\OPENCV_RELEASE.props
....... 421 2015-06-05 06:13 TiredTracker-master\TiredTracker\constants.h
....... 1906 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\cl.command.1.tlog
....... 42882 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\CL.read.1.tlog
....... 1958 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\CL.write.1.tlog
....... 2076 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\li
....... 3658 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\li
....... 934 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\li
....... 222 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog\TiredTracker.lastbuildstate
....... 830464 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\vc120.idb
文件 19796 2017-11-22 17:58 TiredTracker-master\TiredTracker\main.cpp
文件 3377 2017-10-01 14:49 TiredTracker-master\TiredTracker\main.dsp
....... 1946 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\cl.command.1.tlog
....... 38208 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\CL.read.1.tlog
....... 1490 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\CL.write.1.tlog
....... 2190 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\li
....... 4494 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\li
....... 716 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\li
....... 224 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog\TiredTracker.lastbuildstate
....... 4111 2015-06-05 06:13 TiredTracker-master\TiredTracker\TiredTracker.vcxproj
....... 1055 2015-06-05 06:13 TiredTracker-master\TiredTracker\TiredTracker.vcxproj.filters
文件 327680 2017-10-01 14:50 TiredTracker-master\TiredTracker.sdf
....... 960 2015-06-05 06:13 TiredTracker-master\TiredTracker.sln
..A..H. 8704 2017-10-01 14:50 TiredTracker-master\TiredTracker.v11.suo
目录 0 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug\TiredTracker.tlog
目录 0 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release\TiredTracker.tlog
目录 0 2015-06-05 06:13 TiredTracker-master\TiredTracker\Debug
目录 0 2015-06-05 06:13 TiredTracker-master\TiredTracker\Release
目录 0 2017-10-01 14:49 TiredTracker-master\TiredTracker
............此处省略4个文件信息
相关资源
- 基于opencv的C++人眼识别以及眨眼检测
- linux 下 python调用c或者c++编写的代码使
- The C++ IO Streams and Locales
- c++primer 第五版 源代码
- C++ Qt5实现RSA加解密
- MD5算法c++程序设计实现
- 链表实现集合的交叉并运算c++.cpp
- QT编写的电子时钟 c++源码
- 学生成绩管理系统C++QT可视化
- 用C++,QT画分形图
- 南航C++课程设计含课设报告
- 华容道基本功能c++实现
- 基于暗通道和导向滤波的图像去雾算
- 根据原图和二值图得到分割彩图
- qt界面化实现各种滤波函数
- 学生社团管理系统数据结构课程设计
- c#通过dll读取opencv里的mat图片
- python35_d.lib
- C++十进制加减法
- K近邻算法c/c++
- C++实现8方向A*算法
- Pthread 多线程C++动态库+静态库+头文件
- VC++的.cpp文件调用CUDA的.cu文件中的函
- WOA鲸鱼优化算法 C++实现
- 黄金矿工游戏源码c++
- C++API中文版CHM
- windows后台监听键盘事件vs mfc版
- icp C++实现包含测试数据
- 多项式计算
- 诊所信息管理系统C++课程设计报告
评论
共有 条评论