資源簡(jiǎn)介
gige vision PC端代碼,在windows和linux平臺(tái)上可用。 降分分享,希望能幫助有緣人
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“GigEVision.h“
#include?“Gvcp.h“
#include?“GenICam.h“
GenICamManager::GenICamManager(GigEVision&?gev):
??????m_gev(gev)
{
}
void?GenICamManager::ReadxmlFile()
{
??std::vector?data?=?m_gev.Gvcp().ReadBlock(GENICAM_ZIPFILEINFO_ADDRESS?512);
??std::string?sTxt(data.begin()?data.end());
??std::vector?aParts;
??boost::algorithm::split(aParts?sTxt?boost::algorithm::is_any_of(“;“));
??if(aParts.size()?!=?3)
????throw?std::runtime_error(“Error?getting?genicam?file?location?on?camera“);
??int?nAddr?nSize;
??std::stringstream?ss;
??ss?<??ss?>>?nAddr;
??ss.clear();
??ss?<??ss?>>?nSize;
??data?=?m_gev.Gvcp().ReadBlock(nAddr?nSize);
??//?TODO:?find?a?way?to?decompress?the?zip-file?in?menory?without?writing?the?file?to?disk
??//?TODO:?use?a?platform?independent?path
??std::string?sFilename(“/tmp/genicam.zip“);
??std::string?retData;
??try
??{
????std::ofstream?os(sFilename.c_str()?std::ios::binary);
????os.write((char*)(&data[0])?data.size());
????os.flush();
????struct?zip*?zz?=?zip_open(sFilename.c_str()?0?0);
????if(zz?==?0)
??????throw?std::runtime_error(“Error?opening?genicam?zipfile“);
????struct?zip_file*?zf?=?zip_fopen_index(zz?0?0);
????if(zf?==?0)
??????throw?std::runtime_error(“Error?opening?file?in?zip?archive“);
????boost::array?buff;
????int?nRead?=?0;
????while((nRead?=?zip_fread(zf?buff.data()?buff.size()))?!=?0)
??????std::copy(buff.begin()?buff.begin()+nRead?std::back_inserter(retData));
????//?clean?up?file?from?disk
????boost::filesystem::remove(sFilename);
??}
??catch(std::exception&?e)
??{
????boost::filesystem::remove(sFilename);
????throw?e;
??}
??setenv(“GENICAM_ROOT_V1_1“?GENICAM_ROOT_PATH?true);
??m_cam._LoadxmlFromString(retData.c_str());
}
uint32_t?GenICamManager::GetAddress(const?std::string&?sKey)
{
??GenApi::INode*?pN?=?m_cam._GetNode(sKey.c_str());
??uint32_t?nAddr?=?0;
??if(pN?!=?0)
??{
????GenICam::gcstring?val?att;
????if(pN->GetProperty(“Address“?val?att))
????{
??????nAddr?=?boost::lexical_cast(val);
????}
????if(pN->GetProperty(“pAddress“?val?att)?&&?val.length()?>?0)
????{
??????std::string?sTmp(val);
??????std::vector?parts;
??????boost::algorithm::split(parts?sTmp?boost::algorithm::is_any_of(“\t“));
??????for(size_t?i=0;?i ??????{
????????GenApi::INode*?pAddrNode?=?m_cam._GetNode(parts[i].c_str());
????????assert(pAddrNode);
????????GenICam::gcstring?sAddr?sAtt;
????????assert(pAddrNode->GetProperty(“Value“?sAddr?sAtt));
????????nAddr?+=?boost::lexical_cast(sAddr);
??????}
????}
??}
??else
????throw?std::runtime_error(str(boost:
- 上一篇:初等數(shù)論-潘承洞
- 下一篇:netlogo中文使用手冊(cè)
評(píng)論
共有 條評(píng)論