资源简介
基于opencv,用C++开发的基于模板匹配的,红外光照明下的实时瞳孔识别算法,带有搜索域跟踪功能,i7下cpu上处理能达到30fps以上

代码片段和文件信息
#include “tempMatchPupilDetect.h“
using namespace std;
using namespace cv;
VideoWriter outPutMaskoutPutContouroutPutProccessed;
int main() {
int videoSource=0;//0:read video file ; 1: open webcam
long totalframeNumber;
cv::VideoCapture capture;
long frameToStart = 10;
long frameIndex=frameToStart;
cv::Point2d center = cv::Point2d(0 0);
cv::Mat framepreframe;
cv::Rect roi;
int key;
int flag;
double scale =0.5;
Mat imgDiffAcumu;
int patchThre = 0;
int pupilMissCount =0;
Mat templateImg;
int pupilSizeMin = 9;
int pupilSizeMax = 10000;
int debugTag = 1;
if(!videoSource){
capture.open(“1.avi“);
totalframeNumber = capture.get(CV_CAP_PROP_frame_COUNT);
capture.set( CV_CAP_PROP_POS_frameSframeToStart);
cout<<“start frame:“<ameToStart<<“ to read“< else{
capture.open(0);
totalframeNumber = 100000000;}
if(!capture.isOpened())
cout<<“fail to open video source!“< double rate = capture.get(CV_CAP_PROP_FPS);
cout<<“fps:“<
//reading one frame for the preframe for calculate optical flow
if(!capture.read(frame)){
cout<<“reading frame failure“< return -1;}
frameIndex++;
roi = cv::Rect(0 0 0 0);
templateImg = Mat::ones(201201CV_8UC1)*255;
circle(templateImg
Point(101101)
50
0
-1
LINE_8);
namedWindow(“template from algrithm“);
imshow(“template from algrithm“templateImg);
if(debugTag){
outPutMask.open(“./mask.avi“ CV_FOURCC(‘D‘ ‘I‘ ‘V‘ ‘X‘) 30Size(200200) false);
outPutContour.open(“./contour.avi“ CV_FOURCC(‘D‘ ‘I‘ ‘V‘ ‘X‘) 30Size(200200) false);
outPutProccessed.open(“./proccessed.avi“CV_FOURCC(‘D‘ ‘I‘ ‘V‘ ‘X‘) 30Size(frame.colsframe.rows) true);
if (!outPutMask.isOpened()||!outPutContour.isOpened()||!outPutProccessed.isOpened()){
cout << “Could not open the output video for write: “ << endl;
return -1;
}
}
//start the detect task loop
while (key!=27 && key!= 1048603 && frameIndex < totalframeNumber) { //Esc key value in win is 27 and in linux is 1048603
double t = (double)cvGetTickCount(); //calculate the cost time
std::swap(preframe frame);
if(!capture.read(frame)){
cout<<“reading frame failure“< return -1;
}
std::cout<<“totalframeNumber:“<ameNumber<<“ frameIndex:“<ameIndex<
monoPupilDetect(frametemplateImgroicenterflagpatchThrepupilMissCountpupilSizeMinpupilSizeMaxdebugTag);
// opticalFlowPupilDetect(preframeframescaleroicenterflag);
// imgDiffProcess(preframeframeimgDiffAcumuscaleroi);
frameIndex++;
key = waitKey(1);
cout
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 89057 2019-03-18 20:10 pupil_extract_20170701\example.png
文件 884897 2019-03-18 20:19 pupil_extract_20170701\example2.png
文件 3564 2019-03-18 20:08 pupil_extract_20170701\main.cpp
文件 1222 2019-03-18 20:06 pupil_extract_20170701\pupil_extract.pro
文件 24118 2019-03-18 20:16 pupil_extract_20170701\pupil_extract.pro.user
文件 299 2019-03-18 20:15 pupil_extract_20170701\readme.txt
文件 16492 2017-07-01 01:57 pupil_extract_20170701\tempMatchPupilDetect.cpp
文件 912 2019-03-18 20:00 pupil_extract_20170701\tempMatchPupilDetect.h
目录 0 2019-03-18 20:20 pupil_extract_20170701
----------- --------- ---------- ----- ----
1020561 9
- 上一篇:modbus完整协议源码c/c++
- 下一篇:C语言环形队列
相关资源
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 使用QWT库实现接收串口数据,并根据
- 嵌入式QtC++编程课件
- FREERTOS 实时内核 实用指南
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
评论
共有 条评论