资源简介
基于OpenCV的智能视频监控系统设计,使用VS2010和OpenCV2.4.9完成系统设计,压缩包包含整个solution。在安装好VS2010和配置好OpenCV包含等的情况下,可以直接加压缩,点击.sln文件打开整个项目。压缩包内容为智能视频监控的整个project(包含源码)。具体实现方法是利用帧差法获得差分图像,分析差分图像得出物体运动的轨迹和拍照录像与警报等。
代码片段和文件信息
#include
#include
#include
using namespace std;
using namespace cv;
int videoplay();
void on_Trackbar(int void*);
char* str_gettime();
int bSums(Mat src);
char g_str[17];
int g_nNum = 0;//图片名称
int g_nDelay = 0;
int g_npic = 0;
Mat g_filpdstMat;
int g_pointnum = 1000;//设置像素点阈值生成图片
int g_pixel = 0;//像素点
int main()
{
VideoCapture capture(0);
//视频输出VideoWriter
CvVideoWriter* outavi = NULL;
//VideoWriter outavi;
//outavi.open(“sre.avi“-1 5.0 Size(640 480) true);
outavi = cvCreateVideoWriter(“录像.avi“ -1 5.0 cvSize(640 480) 1);
namedWindow(“摄像头“WINDOW_AUTOSIZE);
namedWindow(“移动轨迹“WINDOW_AUTOSIZE);
IplImage *pcpframe = NULL;
Mat tempframe currentframe preframe cpframe;
Mat framejpg;
int framenum = 0;
//读取一帧处理
while (1)
{
if(!capture.isOpened())
{
cout << “读取失败“ << endl;
return -1;
}
capture >> frame;//读取摄像头把每一帧传给frame
frame.copyTo(cpframe);//把frame赋给cpframe,不影响frame
tempframe = frame;//把frame赋给tempframe,影响frame
flip(tempframeg_filpdstMat1);//水平翻转图像
pcpframe = &IplImage(cpframe);//为了释放窗口,把Mat转化为IplImage使用
//cpframe=cvarrToMat(pcpframe);
//ipl转化矩阵 pBinary = &IplImage(Img)
//7帧截取一次录入视频,频繁截取运转不过来
if(framenum % 7 == 0)
{
//录像写入
cvWriteframe(outavi pcpframe);
}
//判断帧数,若为第一帧,把该帧作为对比帧
//若大于等于第二帧,则进行帧差法处理
framenum++;
if (framenum == 1)
{
cvtColor(g_filpdstMat preframe CV_BGR2GRAY);
}
if (framenum >= 2)
{
cvtColor(g_filpdstMat currentframe CV_BGR2GRAY);
//灰度图
absdiff(currentframepreframecurrentframe);//帧差法
threshold(currentframe currentframe 30 255.0 CV_THRESH_BINARY);
//二值化
erode(currentframe currentframeMat());//腐蚀
dilate(currentframe currentframeMat());//膨胀
g_pixel = bSums(currentframe);//调用函数bSums,计算白色像素点,赋值给g_pixel
//小延迟后输出当前像素点数值,防止数据刷太快看不清
g_nDelay++;
if(g_nDelay > 5)
{
cout<< “当前白色像素点:“ < cout << “按ESC退出“ << endl;
g_nDelay = 0;
}
//创建像素点滑轨
createTrackbar(“像素点:““移动轨迹“&g_pointnum 20000on_Trackbar);
on_Trackbar(0 0);//调用回调函数
//显示图像
imshow(“摄像头“ g_filpdstMat);
imshow(“移动轨迹“ currentframe);
}
//把当前帧保存作为下一次处理的前一帧
cvtColor(g_filpdstMat preframe CV_BGR2GRAY);
//判断退出,并销毁录像窗口,否则下一步录像无法打开
if((char)waitKey(10) == 27){cvReleaseVideoWriter(&outavi);break;}
}//end while
while(1)
{
//显示提示窗口
jpg = imread(“模式选择.jpg“ 1);
imshow(“模式选择“jpg);
//设置key选择操作
char key;
key = waitKey(0);
if(key == ‘p‘ || key == ‘P‘)//播放视频
videoplay();
if(key == ‘q‘ || key == ‘Q‘)//退出
break;
}
return 0;
}
//打开录像
int videoplay()
{
VideoCapture video(“录像.avi“);
if(!video.isOpened())
{
fprintf(stderr“打开失败\n“);
return false;
}
while(1)
{
Mat frame;
video>>frame;
if(frame.emp
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
.CA.... 4005 2019-03-31 09:54 cv_track_final\cv_track_final\cv_track_final.vcxproj
.CA.... 957 2019-03-19 15:55 cv_track_final\cv_track_final\cv_track_final.vcxproj.filters
.CA.... 143 2019-03-19 15:51 cv_track_final\cv_track_final\cv_track_final.vcxproj.user
.CA.... 4909 2019-03-23 03:20 cv_track_final\cv_track_final\cv_track_final_main.cpp
.CA.... 822 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cl.command.1.tlog
.CA.... 17852 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\CL.read.1.tlog
.CA.... 492 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\CL.write.1.tlog
.CA.... 667 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final.exe.em
.CA.... 732 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final.exe.em
.CA.... 381 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final.exe.intermediate.manifest
.CA.... 69 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final.lastbuildstate
.CA.... 4699 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final.log
.CA.... 713 2019-03-19 16:35 cv_track_final\cv_track_final\Debug\cv_track_final.vcxprojResolveAssemblyReference.cache
.CA.... 0 2019-03-19 15:55 cv_track_final\cv_track_final\Debug\cv_track_final.write.1.tlog
.CA.... 391728 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\cv_track_final_main.obj
.CA.... 218 2019-03-19 16:00 cv_track_final\cv_track_final\Debug\cv_track_final_manifest.rc
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
.CA.... 2 2019-03-31 09:54 cv_track_final\cv_track_final\Debug\li
............此处省略32个文件信息
相关资源
- 基于 opencv 的车牌识别147642
- One cut in grabcut的OpenCV实现代码以及工
- opencv2.4.4库(.h/.lib/.dll)
- 摄像头实时监控与报警系统Opencv
- opencv在播放视频中画框框
- 学习OpenCV(中文版).pdf 高清版本
- 模板匹配算法实现
- Computer Vision with Opencv3 and Qt5.pdf
- 基于Opencv的手势识别147077
- 基于opencv的车辆检测
- opencv2.4.9 相机定标及图像矫正
- opencv2+vs2013实现表情识别 ,SVM+BP神经
- 基于opencv的三种人脸识别
- opencv求取多轮廓质心并在输出图像显
- 自己写的QT图像处理系统,和opencv进行
- OpenCV计算机视觉常用测试图
- 基于opencv颜色识别 - 图像(普通轮廓
- 基于OpenCV的车辆监测与计数
- 大华相机图像使用OpenCV显示
- opencv的单目标定API已经二次封装
- opencv_install
- 基于OpenCV的运动物体方向识别论文
- 基于Hough椭圆检测opencv
- 抠图代码opencv
- 基于opencv的鱼眼相机标定和透视投影
- MinGW编译的opencv3.2
- 基于 vs2010 opencv的人脸识别系统
- 鱼眼标定校正 opencv3.0 视场大小可调
- opencv 鱼眼镜头标定校正
- Qt5.9.3+mingw530_32+OpenCV3.4.1工程模版
评论
共有 条评论