• 大小: 13KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签: OpenCv  Qt  

资源简介

读取视频,根据移动检测与行人检测做的一个监控人数的程序,运行环境为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

评论

共有 条评论