资源简介

代码实现:使用qt多线程调用海康威视的摄像机,防止界面卡死

资源截图

代码片段和文件信息

#include “CaptureThread.h“
#include “ImageBuffer.h“
#include “opencv2/opencv.hpp“
#include “global.h“
#include “unistd.h“

// Qt header files
#include 
int nPort=0;
volatile int gbHandling=3 ;
unsigned int count=1;


void CALLBACK DecCBFun(int nPort char * pBuf int nSize frame_INFO * pframeInfo void * nReserved1 int nReserved2)
{
    if (gbHandling)
    {
        gbHandling--;
        return;
    }

    long lframeType = pframeInfo->nType;
    if (lframeType == T_YV12)
    {

        Mat pImg(pframeInfo->nHeight pframeInfo->nWidth CV_8UC3);
        Mat src(pframeInfo->nHeight + pframeInfo->nHeight / 2 pframeInfo->nWidth CV_8UC1 pBuf);
        cvtColor(src pImg CV_YUV2BGR_YV12);
    //  Sleep(-1);
        stoppedMutex.lock();//测试是否停止的过程要加锁
         if (stopped)
         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\
     文件         463  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\.qmake.stash
     文件        2710  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\Attendance_Monitoring_System.pro
     文件       24242  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\Attendance_Monitoring_System.pro.user
     文件        6338  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\CaptureThread.cpp
     文件         582  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\CaptureThread.h
     文件        2266  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\Controller.cpp
     文件         732  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\Controller.h
     文件        3904  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\ImageBuffer.cpp
     文件         650  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\ImageBuffer.h
     文件      240949  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\Makefile
     文件        1115  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\MatToQImage.cpp
     文件         233  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\MatToQImage.h
     文件        2188  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\ProcessingThread.cpp
     文件         949  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\ProcessingThread.h
     文件         472  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\README.md
     文件         177  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\global.cpp
     文件         231  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\global.h
     文件         210  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\main.cpp
     文件        1885  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\mainwindow.cpp
     文件         668  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\mainwindow.h
     文件        2606  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\mainwindow.ui
     文件       12529  2018-01-22 04:38  Qt_Hikvsion_multiThread_Opencv-master\multiThread.png

评论

共有 条评论