資源簡(jiǎn)介
大華相機(jī)圖像使用OpenCV顯示,開(kāi)發(fā)平臺(tái)Visual Studio 2015
代碼片段和文件信息
//?DH2OpenCV.cpp?:?定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#include?“stdafx.h“
#include?“GenICam/System.h“
#include?“GenICam/Camera.h“
#include?“StreamRetrieve.h“
#include?
#include?
using?namespace?Dahua::GenICam;
using?namespace?Dahua::Infra;
//給設(shè)備cameraSptr設(shè)置幀率
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;
}
//設(shè)置幀率值
double?frameRateValue?=?75.0;
CDoubleNode?acquisitionframeRate?=?sptrAcquisitionControl->acquisitionframeRate();
if?(!acquisitionframeRate.setValue(frameRateValue))
{
printf(“frameRate?set?failed.\n“);
return;
}
}
int?main()
{
//發(fā)現(xiàn)設(shè)備
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];
//連接設(shè)備
if?(!cameraSptr->connect())
{
printf(“connect?cameral?fail.\n“);
return?-1;
}
//設(shè)置幀率
modifyCamralframeRate(cameraSptr);
//創(chuàng)建流對(duì)象
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();
//停止相機(jī)拉流
streamPtr->stopGrabbing();
//斷開(kāi)設(shè)備
if?(!cameraSptr->disConnect())
{
printf(“disConnect?cameral?fail.\n“);
return?-1;
}
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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\li
?????文件????????4416??2017-07-28?09:40??DH2OpenCV\Debug\DH2OpenCV.tlog\li
?????文件?????????712??2017-07-28?09:40??DH2OpenCV\Debug\DH2OpenCV.tlog\li
?????文件??????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\fr
?????文件????????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個(gè)文件信息
- 上一篇:Test2.zip
- 下一篇:geoda最新版軟件,功能豐富,親試有用
評(píng)論
共有 條評(píng)論