本文整理汇总了C++中Metadata::Serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Metadata::Serialize方法的具体用法?C++ Metadata::Serialize怎么用?C++ Metadata::Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Metadata
的用法示例。
在下文中一共展示了Metadata::Serialize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertImage
/*
* Inserts Image and MetaData into MMCore circular Buffer
*/
int ThorlabsUSBCam::InsertImage()
{
// Image metadata
Metadata md;
char label[MM::MaxStrLength];
this->GetLabel(label);
md.put("Camera", label);
md.put(MM::g_Keyword_Metadata_StartTime, CDeviceUtils::ConvertToString(sequenceStartTime_.getMsec()));
md.put(MM::g_Keyword_Elapsed_Time_ms, CDeviceUtils::ConvertToString((GetCurrentMMTime() - sequenceStartTime_).getMsec()));
md.put(MM::g_Keyword_Metadata_ImageNumber, CDeviceUtils::ConvertToString(imageCounter_));
imageCounter_++;
MMThreadGuard g(imgPixelsLock_);
int ret = GetCoreCallback()->InsertImage(this, img_.GetPixels(),
img_.Width(),
img_.Height(),
img_.Depth(),
md.Serialize().c_str());
if (!stopOnOverFlow_ && ret == DEVICE_BUFFER_OVERFLOW)
{
// do not stop on overflow, reset the buffer and insert the same image again
GetCoreCallback()->ClearImageBuffer(this);
return GetCoreCallback()->InsertImage(this, img_.GetPixels(),
img_.Width(),
img_.Height(),
img_.Depth(),
md.Serialize().c_str());
} else
return ret;
}
示例2: InsertImage
/*
* Inserts Image and MetaData into MMCore circular Buffer
*/
int CIDS_uEye::InsertImage()
{
MM::MMTime timeStamp = this->GetCurrentMMTime();
char label[MM::MaxStrLength];
this->GetLabel(label);
// Important: metadata about the image are generated here:
Metadata md;
/*
// Copy the metadata inserted by other processes:
std::vector<std::string> keys = metadata_.GetKeys();
for (unsigned int i= 0; i < keys.size(); i++) {
MetadataSingleTag mst = metadata_.GetSingleTag(keys[i].c_str());
md.PutTag(mst.GetName(), mst.GetDevice(), mst.GetValue());
}
*/
// Add our own metadata
md.put("Camera", label);
md.put(MM::g_Keyword_Metadata_StartTime, CDeviceUtils::ConvertToString(sequenceStartTime_.getMsec()));
md.put(MM::g_Keyword_Elapsed_Time_ms, CDeviceUtils::ConvertToString((timeStamp - sequenceStartTime_).getMsec()));
md.put(MM::g_Keyword_Metadata_ImageNumber, CDeviceUtils::ConvertToString(imageCounter_));
md.put(MM::g_Keyword_Metadata_ROI_X, CDeviceUtils::ConvertToString( (long) roiX_));
md.put(MM::g_Keyword_Metadata_ROI_Y, CDeviceUtils::ConvertToString( (long) roiY_));
imageCounter_++;
char buf[MM::MaxStrLength];
GetProperty(MM::g_Keyword_Binning, buf);
md.put(MM::g_Keyword_Binning, buf);
MMThreadGuard g(imgPixelsLock_);
const unsigned char* pI = GetImageBuffer();
unsigned int w = GetImageWidth();
unsigned int h = GetImageHeight();
unsigned int b = GetImageBytesPerPixel();
int ret = GetCoreCallback()->InsertImage(this, pI, w, h, b, md.Serialize().c_str());
if (!stopOnOverflow_ && ret == DEVICE_BUFFER_OVERFLOW)
{
// do not stop on overflow - just reset the buffer
GetCoreCallback()->ClearImageBuffer(this);
// don't process this same image again...
return GetCoreCallback()->InsertImage(this, pI, w, h, b, md.Serialize().c_str(), false);
} else
return ret;
}
示例3: mstCount
/*
* Inserts Image and MetaData into MMCore circular Buffer
*/
int CAndorSDK3Camera::InsertImage()
{
char deviceName[MM::MaxStrLength];
GetProperty(MM::g_Keyword_Name, deviceName);
Metadata md;
MetadataSingleTag mstCount(MM::g_Keyword_Metadata_ImageNumber, deviceName, true);
mstCount.SetValue(CDeviceUtils::ConvertToString(thd_->GetImageCounter()));
md.SetTag(mstCount);
if (0 == thd_->GetImageCounter())
{
sequenceStartTime_ = timeStamp_;
}
stringstream ss;
ss << sequenceStartTime_;
MetadataSingleTag mstStartTime(MM::g_Keyword_Metadata_StartTime, deviceName, true);
mstStartTime.SetValue(ss.str().c_str());
md.SetTag(mstStartTime);
ss.str("");
ss.clear();
double d_result = (timeStamp_-sequenceStartTime_)/static_cast<double>(fpgaTSclockFrequency_);
ss << d_result*1000 << " [" << d_result << " seconds]";
MetadataSingleTag mst(MM::g_Keyword_Elapsed_Time_ms, deviceName, true);
mst.SetValue(ss.str().c_str());
md.SetTag(mst);
MMThreadGuard g(imgPixelsLock_);
const unsigned char * pData = img_.GetPixels();
unsigned int w = img_.Width();
unsigned int h = img_.Height();
unsigned int b = img_.Depth();
int ret = GetCoreCallback()->InsertImage(this, pData, w, h, b, md.Serialize().c_str(), false);
if (!stopOnOverflow_ && ret == DEVICE_BUFFER_OVERFLOW)
{
// do not stop on overflow - just reset the buffer
GetCoreCallback()->ClearImageBuffer(this);
// don't process this same image again...
ret = GetCoreCallback()->InsertImage(this, pData, w, h, b, md.Serialize().c_str(), false);
}
return ret;
}
示例4: SetMetadata
void ImgBuffer::SetMetadata(const Metadata& md)
{
//metadata_ = md;
// Serialize/Restore instead of =operator used to avoid object new/delete
// issues accross the DLL boundary (on Windows)
// TODO: this is inefficient and should be revised
metadata_.Restore(md.Serialize().c_str());
}
示例5: InsertImage
/*
* Inserts Image and MetaData into MMCore circular Buffer
*/
int COpenCVgrabber::InsertImage()
{
MM::MMTime timeStamp = this->GetCurrentMMTime();
char label[MM::MaxStrLength];
this->GetLabel(label);
// Important: metadata about the image are generated here:
Metadata md;
md.put("Camera", label);
md.put(MM::g_Keyword_Metadata_StartTime, CDeviceUtils::ConvertToString(sequenceStartTime_.getMsec()));
md.put(MM::g_Keyword_Elapsed_Time_ms, CDeviceUtils::ConvertToString((timeStamp - sequenceStartTime_).getMsec()));
md.put(MM::g_Keyword_Metadata_ImageNumber, CDeviceUtils::ConvertToString(imageCounter_));
md.put(MM::g_Keyword_Metadata_ROI_X, CDeviceUtils::ConvertToString( (long) roiX_));
md.put(MM::g_Keyword_Metadata_ROI_Y, CDeviceUtils::ConvertToString( (long) roiY_));
imageCounter_++;
char buf[MM::MaxStrLength];
GetProperty(MM::g_Keyword_Binning, buf);
md.put(MM::g_Keyword_Binning, buf);
MMThreadGuard g(imgPixelsLock_);
const unsigned char* pI = GetImageBuffer();
unsigned int w = GetImageWidth();
unsigned int h = GetImageHeight();
unsigned int b = GetImageBytesPerPixel();
int ret = GetCoreCallback()->InsertImage(this, pI, w, h, b, md.Serialize().c_str());
if (!stopOnOverFlow_ && ret == DEVICE_BUFFER_OVERFLOW)
{
// do not stop on overflow - just reset the buffer
GetCoreCallback()->ClearImageBuffer(this);
// don't process this same image again...
return GetCoreCallback()->InsertImage(this, pI, w, h, b, md.Serialize().c_str(), false);
//return GetCoreCallback()->InsertImage(this, pI, w, h, b);
} else
return ret;
}
示例6: InsertImage
int EagleIce::InsertImage()
{
char label[MM::MaxStrLength];
this->GetLabel(label);
Metadata md;
md.put("Camera", label);
int ret = GetCoreCallback()->InsertImage(this, GetImageBuffer(), GetImageWidth(),
GetImageHeight(), GetImageBytesPerPixel(),
md.Serialize().c_str());
g_Self->_capturing = false;
if(liveView_ == 1)
g_device->Start_Integration(&lastResolution);
if (ret == DEVICE_BUFFER_OVERFLOW)
{
// do not stop on overflow - just reset the buffer
GetCoreCallback()->ClearImageBuffer(this);
return GetCoreCallback()->InsertImage(this, GetImageBuffer(), GetImageWidth(),
GetImageHeight(), GetImageBytesPerPixel(),
md.Serialize().c_str());
} else
return ret;
}
示例7: PushImage
/**
* Waits for new image and inserts it in the circular buffer.
* This method is called by the acquisition thread AcqSequenceThread::svc()
* in an infinite loop.
*
* In case of error or if the sequence is finished StopSequenceAcquisition()
* is called, which will raise the stop_ flag and cause the thread to exit.
*/
int DVCCamera::PushImage(int userBufferId) {
// create metadata
char label[MM::MaxStrLength];
this->GetLabel(label);
MM::MMTime timestamp = this->GetCurrentMMTime();
Metadata md;
// Copy the metadata inserted by other processes:
std::vector<std::string> keys = metadata_.GetKeys();
for (unsigned int i = 0; i < keys.size(); i++) {
md.put(keys[i],
metadata_.GetSingleTag(keys[i].c_str()).GetValue().c_str());
}
ImageMetaDataP pMd = userBuffers_.pMeta + userBufferId;
md.put("Camera", label);
md.put(MM::g_Keyword_Metadata_StartTime, dvcStartTs_);
// LARGE_INTEGER perfCounter;
// QueryPerformanceCounter(&perfCounter);
// md.put(MM::g_Keyword_Elapsed_Time_ms,
// (double) (perfCounter.QuadPart - perfStartCounter_.QuadPart)
// / (double) perfFreq_.QuadPart);
md.put(MM::g_Keyword_Elapsed_Time_ms, pMd->dExposeTimeStamp - dvcStartTs_);
md.put(MM::g_Keyword_Metadata_ImageNumber,
CDeviceUtils::ConvertToString((long) (pMd->ulStreamCount)));
md.put(MM::g_Keyword_Binning, binSize_);
md.PutTag(g_hBinning, label, pMd->hBin);
md.PutTag(g_vBinning, label, pMd->vBin);
md.PutTag(g_MD_ExposeTime, label, pMd->dExposeTime);
md.PutTag(g_MD_ExposeTimestamp, label, pMd->dExposeTimeStamp);
md.PutTag(g_MD_FrameTimestamp, label, pMd->dFrameTime);
md.PutTag(g_MD_TransferTime, label, pMd->dTransferTime);
md.PutTag(g_MD_TriggerTimestamp, label, pMd->dTriggerTimeStamp);
const int height = GetImageHeight();
const int width = GetImageWidth();
const int bytesPerPixel = GetImageBytesPerPixel();
imageCounter_++;
// This method inserts new image in the circular buffer (residing in MMCore)
const int retCode = GetCoreCallback()->InsertImage(this,
(const unsigned char*) (userBuffers_.pBuffers[userBufferId]),
(unsigned int) width, (unsigned int) height,
(unsigned int) bytesPerPixel, &md);
if (!stopOnOverflow_ && retCode == DEVICE_BUFFER_OVERFLOW) {
// LogMessage("Overflow occured.");
// do not stop on overflow - just reset the buffer
GetCoreCallback()->ClearImageBuffer(this);
return GetCoreCallback()->InsertImage(this,
(const unsigned char*) (userBuffers_.pBuffers[userBufferId]),
(unsigned int) width, (unsigned int) height,
(unsigned int) bytesPerPixel, md.Serialize().c_str());
}
userBuffers_.pBufferStatus[userBufferId] = 0;
return DEVICE_OK;
}
示例8: mstStartTime
int BitFlowCamera::LiveThread::svc()
{
stopRunning_ = false;
running_ = true;
imageCounter_ = 0;
// put the hardware into a continuous acqusition state
while (true) {
if (stopRunning_)
break;
int ret = cam_->SnapImage();
if (ret != DEVICE_OK) {
char txt[1000];
sprintf(txt, "BitFlow live thread: ImageSnap() error %d", ret);
cam_->GetCoreCallback()->LogMessage(cam_, txt, false);
break;
}
char label[MM::MaxStrLength];
cam_->GetLabel(label);
MM::MMTime timestamp = cam_->GetCurrentMMTime();
Metadata md;
MetadataSingleTag mstStartTime(MM::g_Keyword_Metadata_StartTime, label, true);
mstStartTime.SetValue(CDeviceUtils::ConvertToString(cam_->startTime_.getMsec()));
md.SetTag(mstStartTime);
MetadataSingleTag mstElapsed(MM::g_Keyword_Elapsed_Time_ms, label, true);
MM::MMTime elapsed = timestamp - cam_->startTime_;
mstElapsed.SetValue(CDeviceUtils::ConvertToString(elapsed.getMsec()));
md.SetTag(mstElapsed);
MetadataSingleTag mstCount(MM::g_Keyword_Metadata_ImageNumber, label, true);
mstCount.SetValue(CDeviceUtils::ConvertToString(imageCounter_));
md.SetTag(mstCount);
// insert all channels
for (unsigned i=0; i<cam_->GetNumberOfChannels(); i++)
{
char buf[MM::MaxStrLength];
MetadataSingleTag mstChannel(MM::g_Keyword_CameraChannelIndex, label, true);
snprintf(buf, MM::MaxStrLength, "%d", i);
mstChannel.SetValue(buf);
md.SetTag(mstChannel);
MetadataSingleTag mstChannelName(MM::g_Keyword_CameraChannelName, label, true);
cam_->GetChannelName(i, buf);
mstChannelName.SetValue(buf);
md.SetTag(mstChannelName);
ret = cam_->GetCoreCallback()->InsertImage(cam_, cam_->GetImageBuffer(i),
cam_->GetImageWidth(),
cam_->GetImageHeight(),
cam_->GetImageBytesPerPixel(),
md.Serialize().c_str());
if (ret == DEVICE_BUFFER_OVERFLOW) {
cam_->GetCoreCallback()->ClearImageBuffer(cam_);
cam_->GetCoreCallback()->InsertImage(cam_, cam_->GetImageBuffer(i),
cam_->GetImageWidth(),
cam_->GetImageHeight(),
cam_->GetImageBytesPerPixel(),
md.Serialize().c_str());
}
else if (ret != DEVICE_OK) {
cam_->GetCoreCallback()->LogMessage(cam_, "BitFlow thread: error inserting image", false);
break;
}
}
imageCounter_++;
if (numImages_ >=0 && imageCounter_ >= numImages_) {
cam_->bfDev_.StopContinuousAcq();
break;
}
}
running_ = false;
return 0;
}