• 大小: 15.04MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-19
  • 语言: 其他
  • 标签: 大华  OpenCV  

资源简介

大华相机图像使用OpenCV显示,开发平台Visual Studio 2015

资源截图

代码片段和文件信息

// DH2OpenCV.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“

#include “GenICam/System.h“
#include “GenICam/Camera.h“
#include “StreamRetrieve.h“
#include 
#include 

using namespace Dahua::GenICam;
using namespace Dahua::Infra;

//给设备cameraSptr设置帧率
static void modifyCamralframeRate(ICameraPtr& cameraSptr)
{
IAcquisitionControlPtr sptrAcquisitionControl = CSystem::getInstance().createAcquisitionControl(cameraSptr);
if (NULL == sptrAcquisitionControl)
{
printf(“sptrAcquisitionControl is null.\n“);
return;
}

CBoolNode AcquisitionframeRateEnable = sptrAcquisitionControl->acquisitionframeRateEnable();
if (!AcquisitionframeRateEnable.setValue(true))
{
printf(“frameRateEnable set failed.\n“);
return;
}

//设置帧率值
double frameRateValue = 75.0;
CDoubleNode acquisitionframeRate = sptrAcquisitionControl->acquisitionframeRate();
if (!acquisitionframeRate.setValue(frameRateValue))
{
printf(“frameRate set failed.\n“);
return;
}
}

int main()
{
//发现设备
CSystem &systemObj = CSystem::getInstance();
TVector vCameraPtrList;
bool isDiscoverySuccess = systemObj.discovery(vCameraPtrList);
if (!isDiscoverySuccess)
{
printf(“discovery device fail.\n“);
return -1;
}

if (0 == vCameraPtrList.size())
{
printf(“no camera device find.\n“);
return -1;
}

ICameraPtr cameraSptr = vCameraPtrList[0];
//连接设备
if (!cameraSptr->connect())
{
printf(“connect cameral fail.\n“);
return -1;
}

//设置帧率
modifyCamralframeRate(cameraSptr);

//创建流对象
IStreamSourcePtr streamPtr = systemObj.createStreamSource(cameraSptr);
if (NULL == streamPtr)
{
printf(“create stream obj  fail.\n“);
return -1;
}

bool isStartGrabbingSuccess = streamPtr->startGrabbing();
if (!isStartGrabbingSuccess)
{
printf(“StartGrabbing  fail.\n“);
return -1;
}

//拉流
Dahua::Memory::TSharedPtr streamThreadSptr(new StreamRetrieve(streamPtr));
if (NULL == streamThreadSptr)
{
printf(“create thread obj fail.\n“);
return -1;
}

streamThreadSptr->start();

CThread::sleep(2000);
getchar();


//停止拉流线程
streamThreadSptr->stop();

//停止相机拉流
streamPtr->stopGrabbing();

//断开设备
if (!cameraSptr->disConnect())
{
printf(“disConnect cameral fail.\n“);
return -1;
}

return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-28 09:41  DH2OpenCV\
     文件        2438  2017-07-28 09:41  DH2OpenCV\DH2OpenCV.cpp
     文件        8181  2017-07-28 09:37  DH2OpenCV\DH2OpenCV.vcxproj
     文件        1603  2017-07-28 09:34  DH2OpenCV\DH2OpenCV.vcxproj.filters
     目录           0  2017-07-28 09:40  DH2OpenCV\Debug\
     文件        4113  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.log
     文件      144224  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.obj
     文件     4587520  2017-07-28 09:37  DH2OpenCV\Debug\DH2OpenCV.pch
     目录           0  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\
     文件        2164  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\CL.command.1.tlog
     文件       93232  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\CL.read.1.tlog
     文件        2206  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\CL.write.1.tlog
     文件         199  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\DH2OpenCV.lastbuildstate
     文件        1656  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\link.command.1.tlog
     文件        4416  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\link.read.1.tlog
     文件         712  2017-07-28 09:40  DH2OpenCV\Debug\DH2OpenCV.tlog\link.write.1.tlog
     文件      258628  2017-07-28 09:37  DH2OpenCV\Debug\StreamRetrieve.obj
     文件       11671  2017-07-28 09:37  DH2OpenCV\Debug\stdafx.obj
     文件     1321984  2017-07-28 09:40  DH2OpenCV\Debug\vc140.idb
     文件      929792  2017-07-28 09:40  DH2OpenCV\Debug\vc140.pdb
     文件        2349  2017-07-28 09:32  DH2OpenCV\frameBuffer.h
     文件        1524  2017-07-28 09:29  DH2OpenCV\ReadMe.txt
     文件        6594  2017-07-28 09:34  DH2OpenCV\StreamRetrieve.cpp
     文件         593  2017-07-28 09:34  DH2OpenCV\StreamRetrieve.h
     文件         213  2017-07-28 09:29  DH2OpenCV\stdafx.cpp
     文件         234  2017-07-28 09:29  DH2OpenCV\stdafx.h
     文件         240  2017-07-28 09:29  DH2OpenCV\targetver.h
     文件    35373056  2017-07-28 09:41  DH2OpenCV.VC.db
     文件        1309  2017-07-28 09:29  DH2OpenCV.sln
     目录           0  2017-07-28 09:40  Debug\
     文件       97792  2017-07-28 09:40  Debug\DH2OpenCV.exe
............此处省略123个文件信息

评论

共有 条评论