资源简介
读取视频,根据移动检测与行人检测做的一个监控人数的程序,运行环境为Qt+Opencv,在运行前注意配置好环境
代码片段和文件信息
#include “detectcv.h“
DetectCV::DetectCV(int x int y int width int height)
{
//-- 1. 加载级联分类器文件
if( !face_cascade.load( face_cascade_name ) )
{
printf(“--(!)Error loading\n“);
cout << face_cascade_name << endl;
}
screen = QGuiApplication::primaryScreen();
for(int i=0; i < 3; i++)
{
QString filePathName = “full-“;
filePathName += QString::number(i10);
filePathName += “.jpg“;
screen->grabWindow(0 x y width height).save(filePathName “jpg“);
}
}
/** @函数 detectFace */
int DetectCV::detectFace( )
{
vector faces;
Mat frame_gray;
QString path = “full-“ + QString::number(past10) + “.jpg“;
Mat frame = imread(path.toStdString());
cvtColor( frame frame_gray CV_BGR2GRAY );
equalizeHist( frame_gray frame_gray );
//-- 多尺寸检测人脸
face_cascade.detectMultiScale( frame_gray faces 1.1 2 0|CV_HAAR_SCALE_IMAGE Size(30 30) );
for( int i = 0; i < faces.size(); i++ )
{
Point center( faces[i].x + faces[i].width*0.5 faces[i].y + faces[i].height*0.5 );
ellipse( frame center Size( faces[i].width*0.5 faces[i].height*0.5) 0 0 360 Scalar( 255 0 255 ) 4 8 0 );
}
//-- 显示结果图像
imshow( window_name frame );
return faces.size();
}
/** @函数 detectBody */
int DetectCV::detectBody(Mat framevector boundRect)
{
// QString path = “full-“ + QString::number(past10) + “.jpg“;
// Mat frame = imread(path.toStdString());
std::vector bodys;
HOGDescriptor defaultHog;
defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
//进行检测
defaultHog.detectMultiScale(frame bodys);
//画长方形,框出行人
for(int i = 0; i < bodys.size(); i++)
{
Rect r = bodys[i];
Point center = heightPoint(r);
for(int j = 0; j < boundRect.size(); j++)
{
if(center.x > boundRect[j].x
&& center.x < boundRect[j].x+boundRect[j].width
&& center.y > boundRect[j].y
&& center.y < boundRect[j].y+boundRect[j].height)
{
// if come back
for(int l = 0; l {
if(per_direc[l].bound.x == boundRect[j].x && per_direc[l].bound.y == boundRect[j].y)
{
per_direc[l].preNum++;
per_direc[l].isAppear = true;
// per_direc[l].appearTimes++;
}
}
rectangle(frame r Scalar(0 0 255) 2);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-06-06 17:07 projectCatch\
文件 192 2018-04-13 07:09 projectCatch\main.cpp
文件 24176 2018-04-13 08:39 projectCatch\projectcatch.pro.user
文件 710 2018-05-21 06:14 projectCatch\mainwindow.h
文件 24183 2018-06-01 18:41 projectCatch\projectCatch.pro.user
文件 2750 2018-05-23 04:05 projectCatch\mainwindow.ui
文件 10704 2018-05-31 10:41 projectCatch\detectcv.cpp
文件 1184 2018-05-21 06:37 projectCatch\detectcv.h
文件 59 2018-05-23 07:54 projectCatch\person.cpp
文件 2223 2018-06-06 17:07 projectCatch\mainwindow.cpp
文件 1962 2018-05-16 06:21 projectCatch\projectCatch.pro
文件 371 2018-05-23 07:54 projectCatch\person.h
- 上一篇:有人网络调试助手 串口调试助手二合一
- 下一篇:客户管理模块数据流图
相关资源
- QT编写的Socket工具,TCP 以及 UDP 可建立
- 获取连通域(可根据面积筛选封闭图
- Qt 读取Excel单元格中的数据
- Qt 自定义QPushButton样式表(实时生成
- Qt With WindowsCmd命令行.zip
- QtMineSweep-master.rar
- Qt基于libzplay库的音乐播放工具
- opencv头文件以兹互勉
- Qt 中读写Excel
- Qt TCP 聊天软件
- QT开发的串口通讯软件(基于qextseri
- 视频车辆识别
- 利用QT5.8与opencv3.2做的照片融合
- 用qt设计的显示温度的
- Qt文件或文件夹拷贝
- TCP通信Qt源码
- qt画图程序
- qt 分页显示
- 客户与服务器程序的同步与通信机制
- gameServer
- 基于Qt的HTTP服务器
- QTreeWidget基础操作代码
- Qt4.8.2 模仿QQ桌面右下角消息提示
- QJson使用VS2010+QT4.8编译
- 基于opencv的retinex单尺度实现
- Qt实现全局观察者模式多层窗体之间直
- 用QT做的LINUX下串口通信测试可用
- Qt智能聊天机器人源码
- 基于Delphi的MQTT协议实现(使用INDY无三
- Qt目录树制作
评论
共有 条评论