资源简介
基于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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 421 2015-06-05 06:13 demo\constants.h
文件 19796 2017-11-22 17:58 demo\main.cpp
目录 0 2017-11-23 13:01 demo
----------- --------- ---------- ----- ----
20217 3
相关资源
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- 基于opencv的模板匹配代码
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
- c++ 虚拟摄像头
- hook,捕获所有案件,查找所有窗口,
- C语言课设计算器
- c++ 简易贪吃蛇源码
- 高精度加法(c++代码)
- C++调用百度地图案例
- 北京化工大学计算方法(C/C++)讲义
- 基于VC++的SolidWorks二次开发SolidWorks
- c++ 模拟鼠标按键
- OFD编辑器
- opencv图片扫描以及校正
- Beginning C++17 From Novice to Professional
- C++ STL实现
- opencv手部轮廓识别以及轨迹识别
- 百度C++编码规范
- C++ sql2008 WebServer通讯.docx
- c++ 定时关机程序源码
- opencv2 3D标定.cpp
- 基于VSCode和CMake实现C++开发
- c++语法查询工具
- c++ 账务系统源码
评论
共有 条评论