8 #include "PlusConfigure.h" 9 #ifdef PLUS_RENDERING_ENABLED 16 #include "vtkIGSIOTrackedFrameList.h" 19 #include <vtkImageData.h> 20 #include <vtkMatrix4x4.h> 21 #include <vtkObjectFactory.h> 40 , BlankImage(vtkImageData::New())
41 , SaveRfProcessingParameters(false)
52 this->
BlankImage->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
55 memset(this->
BlankImage->GetScalarPointer(), 0, memorysize);
79 const char*
id = aChannelElement->GetAttribute(
"Id");
82 LOG_ERROR(
"No stream id defined. It is required for all streams.");
89 LOG_ERROR(
"Channel does not know about its parent device. Unable to configure.");
94 for (
int i = 0;
i < aChannelElement->GetNumberOfNestedElements();
i++)
96 vtkXMLDataElement* aSourceElement = aChannelElement->GetNestedElement(
i);
97 if (STRCASECMP(aSourceElement->GetName(),
"DataSource") != 0)
103 const char*
id = aSourceElement->GetAttribute(
"Id");
106 LOG_ERROR(
"No field \"Id\" defined in the source element " << this->
GetChannelId() <<
". Unable to add it to the channel.");
115 this->
Tools[aSource->GetId()] = aSource;
124 this->
Tools[aSource->GetId()] = aSource;
128 LOG_ERROR(
"Unable to find data source with Id=\'" <<
id <<
"\'.");
137 else if (aChannelElement->GetAttribute(
"VideoDataSourceId") != NULL)
139 LOG_ERROR(
"Unable to find video data source that matches Id: " << aChannelElement->GetAttribute(
"VideoDataSourceId"));
144 if (rfElement != NULL)
160 for (
int i = 0;
i < aChannelElement->GetNumberOfNestedElements();
i++)
162 vtkXMLDataElement* attrElement = aChannelElement->GetNestedElement(
i);
163 if (STRCASECMP(attrElement->GetName(),
"Attribute") != 0)
167 const char*
id = attrElement->GetAttribute(
"Id");
170 LOG_ERROR(
"No idea in channel attribute for channel " << this->
GetChannelId());
173 const char*
value = attrElement->GetCharacterData();
176 LOG_ERROR(
"No value set for attribute: " <<
id);
179 std::string strId(
id);
189 aChannelElement->SetAttribute(
"Id", this->
GetChannelId());
191 for (
int i = 0;
i < aChannelElement->GetNumberOfNestedElements();
i++)
193 vtkXMLDataElement* element = aChannelElement->GetNestedElement(
i);
194 if (STRCASECMP(element->GetName(),
"DataSource") != 0)
209 if (element->GetAttribute(
"Id") == NULL || this->
GetTool(aTool, element->GetAttribute(
"Id")) !=
PLUS_SUCCESS)
211 LOG_ERROR(
"Unable to retrieve tool when saving config.");
221 LOG_ERROR(
"Unable to retrieve field data source when saving config.");
230 vtkXMLDataElement* rfElement = aChannelElement->FindNestedElementWithName(
"RfProcessing");
240 if (toolSourceId.empty())
242 LOG_ERROR(
"vtkPlusChannel::GetTool failed: toolSourceId is invalid");
248 if (toolSourceId == it->second->GetId())
261 if (portName.empty())
263 LOG_ERROR(
"vtkPlusChannel::GetToolByPortName failed: portName is invalid");
269 if (portName == it->second->GetPortName())
284 LOG_ERROR(
"Trying to add null tool to channel.");
290 if (it->second == aTool)
297 this->
Tools[aTool->GetId()] = aTool;
298 this->
Tools[aTool->GetId()]->Register(
this);
313 if (toolSourceId.empty())
315 LOG_ERROR(
"vtkPlusChannel::RemoveTool failed: toolSourceId is invalid");
321 if (it->second->GetId() == toolSourceId)
323 this->
Tools.erase(it);
349 LOG_ERROR(
"Trying to add null field data source to channel.");
355 if (it->second == aSource)
371 if (sourceId.empty())
373 LOG_ERROR(
"vtkPlusChannel::RemoveFieldDataSource failed: sourceId is invalid");
379 if (it->second->GetId() == sourceId)
392 if (sourceId.empty())
394 LOG_ERROR(
"vtkPlusChannel::GetFieldDataSource failed: sourceId is invalid");
400 if (sourceId == it->second->GetId())
402 aSource = it->second;
446 LOG_ERROR(
"Unable to retrieve latest timestamp from the video source buffer.");
483 if (otherObject == NULL)
511 LOG_ERROR(
"Unable to add a tool when shallow copying a channel.");
519 LOG_ERROR(
"Unable to add a field data source when shallow copying a channel.");
534 int numberOfErrors(0);
535 double synchronizedTimestamp(0);
542 LOG_ERROR(
"Couldn't get tracked frame from video source, frames are not available yet");
551 LOG_ERROR(
"Couldn't get frame UID from time (" << std::fixed <<
timestamp <<
552 ") - item not available anymore!");
556 LOG_ERROR(
"Couldn't get frame UID from time (" << std::fixed <<
timestamp <<
557 ") - item not available yet!");
561 LOG_ERROR(
"Couldn't get frame UID from time (" << std::fixed <<
timestamp <<
")!");
570 LOG_ERROR(
"Couldn't get video buffer item by frame UID: " << frameUID);
575 igsioVideoFrame frame = CurrentStreamBufferItem.
GetFrame();
576 aTrackedFrame.SetImageData(frame);
580 for (igsioFieldMapType::const_iterator fieldIterator = fieldMap.begin(); fieldIterator != fieldMap.end(); fieldIterator++)
582 aTrackedFrame.SetFrameField((*fieldIterator).first, (*fieldIterator).second.second, fieldIterator->second.first);
588 if (synchronizedTimestamp == 0)
594 aTrackedFrame.SetTimestamp(synchronizedTimestamp);
599 igsioTransformName toolTransformName(aTool->GetId());
600 if (!toolTransformName.IsValid())
602 LOG_ERROR(
"Tool transform name is invalid!");
611 double latestTimestamp(0);
614 LOG_ERROR(
"Failed to get latest timestamp!");
618 double oldestTimestamp(0);
621 LOG_ERROR(
"Failed to get oldest timestamp!");
625 LOG_ERROR(aTool->GetId() <<
": Failed to get tracker item from buffer by time: " << std::fixed << synchronizedTimestamp <<
" (Latest timestamp: " << latestTimestamp <<
" Oldest timestamp: " << oldestTimestamp <<
").");
630 vtkSmartPointer<vtkMatrix4x4> dMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
633 LOG_ERROR(
"Failed to get matrix from buffer item for tool " << aTool->GetId());
638 if (aTrackedFrame.SetFrameTransform(toolTransformName, dMatrix) !=
PLUS_SUCCESS)
640 LOG_ERROR(
"Failed to set transform for tool " << aTool->GetId());
645 if (aTrackedFrame.SetFrameTransformStatus(toolTransformName, bufferItem.
GetStatus()) !=
PLUS_SUCCESS)
647 LOG_ERROR(
"Failed to set transform status for tool " << aTool->GetId());
654 igsioFieldMapType::iterator fieldIterator;
655 for (igsioFieldMapType::const_iterator fieldIterator = fieldMap.begin(); fieldIterator != fieldMap.end(); fieldIterator++)
657 aTrackedFrame.SetFrameField(fieldIterator->first, fieldIterator->second.second, fieldIterator->second.first);
671 double latestTimestamp(0);
674 LOG_ERROR(
"Failed to get latest timestamp!");
678 double oldestTimestamp(0);
681 LOG_ERROR(
"Failed to get oldest timestamp!");
685 LOG_ERROR(aSource->GetId() <<
": Failed to get tracker item from buffer by time: " << std::fixed << synchronizedTimestamp <<
" (Latest timestamp: " << latestTimestamp <<
" Oldest timestamp: " << oldestTimestamp <<
").");
692 for (igsioFieldMapType::const_iterator fieldIterator = fieldMap.begin(); fieldIterator != fieldMap.end(); fieldIterator++)
694 aTrackedFrame.SetFrameField(fieldIterator->first, fieldIterator->second.second, fieldIterator->second.first);
701 aTrackedFrame.SetTimestamp(synchronizedTimestamp);
709 double mostRecentFrameTimestamp(0);
711 "Failed to get most recent timestamp from the buffer!");
719 LOG_TRACE(
"vtkPlusDevice::GetTrackedFrameList(" << aTimestampOfLastFrameAlreadyGot <<
", " << aMaxNumberOfFramesToAdd <<
")");
721 if (aTrackedFrameList == NULL)
723 LOG_ERROR(
"Unable to get tracked frame list - output tracked frame list is NULL!");
732 LOG_DEBUG(
"vtkPlusDataCollector::GetTrackedFrameList: the video buffer is empty, no items will be returned");
742 LOG_ERROR(
"Failed to get timestamp master tool");
747 LOG_DEBUG(
"vtkPlusDataCollector::GetTrackedFrameList: the tracker buffer is empty, no items will be returned");
753 double mostRecentTimestamp(0);
754 static vtkIGSIOLogHelper logHelper(60.0, 500000);
756 "Unable to get most recent timestamp!");
759 double oldestTimestamp(0);
762 LOG_ERROR(
"Failed to get oldest timestamp from buffer!");
767 double timestampFrom = aTimestampOfLastFrameAlreadyGot;
768 if (aTimestampOfLastFrameAlreadyGot == UNDEFINED_TIMESTAMP)
770 timestampFrom = mostRecentTimestamp;
773 if (timestampFrom < oldestTimestamp)
775 LOG_ERROR(
"Items are requested from " << timestampFrom <<
", but the oldest available data is acquired at " << oldestTimestamp);
779 if (aMaxNumberOfFramesToAdd > 0)
786 LOG_ERROR(
"Failed to get video buffer item by timestamp " << mostRecentTimestamp);
792 LOG_ERROR(
"Failed to get video buffer item by timestamp " << timestampFrom);
797 if (mostRecentVideoUid - videoUidFrom + 1 > aMaxNumberOfFramesToAdd)
800 firstVideoUidToAdd = mostRecentVideoUid - aMaxNumberOfFramesToAdd + 1;
804 LOG_TRACE(
"Number of frames in the video buffer is less than maxNumberOfFramesToAdd (more data is allowed to be recorded than it was provided by the data sources)");
809 LOG_ERROR(
"Failed to get video buffer timestamp from UID: " << firstVideoUidToAdd);
818 LOG_ERROR(
"Failed to get tracked frame list - there is no active tool!");
825 LOG_ERROR(
"Failed to get tracked buffer item by timestamp " << mostRecentTimestamp);
835 LOG_ERROR(
"Failed to get tracker buffer item by timestamp " << timestampFrom <<
". Item not available yet.");
838 LOG_ERROR(
"Failed to get tracker buffer item by timestamp " << timestampFrom <<
". Item not available anymore.");
842 LOG_ERROR(
"Failed to get tracker buffer item by timestamp " << timestampFrom);
849 if (mostRecentTrackerUid - trackerUidFrom + 1 > aMaxNumberOfFramesToAdd)
852 firstTrackerUidToAdd = mostRecentTrackerUid - aMaxNumberOfFramesToAdd + 1;
856 LOG_TRACE(
"Number of frames in the tracker buffer is less than maxNumberOfFramesToAdd (more data is allowed to be recorded than it was provided by the data sources)");
861 LOG_ERROR(
"Failed to get tracker buffer timestamp from UID: " << firstTrackerUidToAdd);
872 LOG_ERROR(
"Failed to get tracked buffer item by timestamp " << mostRecentTimestamp);
882 LOG_ERROR(
"Failed to get field buffer item by timestamp " << timestampFrom <<
". Item not available yet.");
885 LOG_ERROR(
"Failed to get field buffer item by timestamp " << timestampFrom <<
". Item not available anymore.");
889 LOG_ERROR(
"Failed to get field buffer item by timestamp " << timestampFrom);
896 if (mostRecentSourceUid - sourceUidFrom + 1 > aMaxNumberOfFramesToAdd)
899 firstSourceUidToAdd = mostRecentSourceUid - aMaxNumberOfFramesToAdd + 1;
903 LOG_TRACE(
"Number of frames in the field buffer is less than maxNumberOfFramesToAdd (more data is allowed to be recorded than it was provided by the data sources)");
908 LOG_ERROR(
"Failed to get field buffer timestamp from UID: " << firstSourceUidToAdd);
915 if (timestampFrom > mostRecentTimestamp)
917 timestampFrom = mostRecentTimestamp;
919 else if (timestampFrom < oldestTimestamp)
921 timestampFrom = oldestTimestamp;
927 int numberOfFramesToAdd = 0;
928 if (aMaxNumberOfFramesToAdd > 0)
930 numberOfFramesToAdd = std::min(aMaxNumberOfFramesToAdd, numberOfFramesSinceTimestamp);
934 numberOfFramesToAdd = numberOfFramesSinceTimestamp;
937 LOG_TRACE(
"Number of added frames: " << numberOfFramesToAdd <<
" out of " << numberOfFramesSinceTimestamp);
941 if (numberOfFramesToAdd == 0)
943 timestampFrom = mostRecentTimestamp;
946 for (
int i = 0;
i < numberOfFramesToAdd; ++
i)
949 if (timestampFrom > aTimestampOfLastFrameAlreadyGot || aTimestampOfLastFrameAlreadyGot == UNDEFINED_TIMESTAMP)
952 igsioTrackedFrame* trackedFrame =
new igsioTrackedFrame;
957 LOG_ERROR(
"Unable to get tracked frame by time: " << std::fixed << timestampFrom);
962 aTimestampOfLastFrameAlreadyGot = trackedFrame->GetTimestamp();
963 if (aTrackedFrameList->TakeTrackedFrame(trackedFrame, vtkIGSIOTrackedFrameList::SKIP_INVALID_FRAME) !=
PLUS_SUCCESS)
965 LOG_ERROR(
"Unable to add tracked frame to the list!");
976 LOG_ERROR(
"Failed to get video buffer item UID from time: " << std::fixed << timestampFrom);
982 LOG_WARNING(
"Requested video uid (" << videoUid + 1 <<
") is not in the buffer yet!");
989 LOG_ERROR(
"Unable to get timestamp from video buffer by UID: " << videoUid);
998 LOG_ERROR(
"Failed to get tracked frame list - there is no active tool!");
1005 LOG_ERROR(
"Failed to get tracker buffer item UID from time: " << std::fixed << timestampFrom);
1011 LOG_ERROR(
"Requested tracker uid (" << trackerUid + 1 <<
") is not in the buffer yet!");
1018 LOG_WARNING(
"Unable to get timestamp from tracker buffer by UID: " << trackerUid);
1029 LOG_ERROR(
"Failed to get tracker buffer item UID from time: " << std::fixed << timestampFrom);
1035 LOG_ERROR(
"Requested tracker uid (" << fieldUid + 1 <<
") is not in the buffer yet!");
1042 LOG_WARNING(
"Unable to get timestamp from field data buffer by UID: " << fieldUid);
1054 LOG_TRACE(
"vtkPlusDataCollector::GetTrackedFrameListSampled: aTimestampOfLastFrameAlreadyGot=" << aTimestampOfLastFrameAlreadyGot <<
", aTimestampOfNextFrameToBeAdded=" << aTimestampOfNextFrameToBeAdded <<
", aSamplingPeriodSec=" << aSamplingPeriodSec);
1056 if (aTrackedFrameList == NULL)
1058 LOG_ERROR(
"vtkPlusChannel::GetTrackedFrameListSampled failed: unable to get tracked frame list. Output tracked frame list is NULL.");
1062 double startTimeSec = vtkIGSIOAccurateTimer::GetSystemTime();
1064 double mostRecentTimestamp(0);
1066 "vtkPlusChannel::GetTrackedFrameListSampled failed: unable to get most recent timestamp. Probably no frames have been acquired yet.");
1070 for (; aTimestampOfNextFrameToBeAdded <= mostRecentTimestamp; aTimestampOfNextFrameToBeAdded += aSamplingPeriodSec)
1073 if (maxTimeLimitSec > 0 && vtkIGSIOAccurateTimer::GetSystemTime() - startTimeSec > maxTimeLimitSec)
1075 LOG_DEBUG(
"Reached maximum time that is allowed for sampling frames");
1082 double oldestTimestamp = 0;
1085 LOG_ERROR(
"vtkPlusChannel::GetTrackedFrameListSampled: Failed to get oldest timestamp from buffer. Probably no frames have been acquired yet.");
1091 LOG_WARNING(
"vtkPlusChannel::GetTrackedFrameListSampled: Frames in the buffer are not available any more at time: " << std::fixed << aTimestampOfNextFrameToBeAdded <<
". Skipping " << newTimestampOfFrameToBeAdded - aTimestampOfNextFrameToBeAdded <<
" seconds from the recording to catch up. Increase the buffer size or decrease the acquisition rate to avoid this situation.");
1092 aTimestampOfNextFrameToBeAdded = newTimestampOfFrameToBeAdded;
1098 if (closestTimestamp == UNDEFINED_TIMESTAMP)
1100 LOG_ERROR(
"vtkPlusChannel::GetTrackedFrameListSampled: Failed to get closest timestamp from buffer for the next frame. Probably no frames have been acquired yet.");
1103 if (aTimestampOfLastFrameAlreadyGot != UNDEFINED_TIMESTAMP && closestTimestamp <= aTimestampOfLastFrameAlreadyGot)
1109 igsioTrackedFrame* trackedFrame =
new igsioTrackedFrame;
1112 LOG_WARNING(
"vtkPlusChannel::GetTrackedFrameListSampled: Unable retrieve frame from the devices for time: " << std::fixed << aTimestampOfNextFrameToBeAdded <<
", probably the item is not available in the buffers anymore. Frames may be lost.");
1113 delete trackedFrame;
1116 aTimestampOfLastFrameAlreadyGot = trackedFrame->GetTimestamp();
1118 if (aTrackedFrameList->TakeTrackedFrame(trackedFrame, vtkIGSIOTrackedFrameList::SKIP_INVALID_FRAME) !=
PLUS_SUCCESS)
1120 LOG_ERROR(
"vtkPlusChannel::GetTrackedFrameListSampled: Unable to add tracked frame to the list");
1136 double oldestVideoTimestamp(std::numeric_limits<double>::max());
1141 LOG_WARNING(
"Failed to get oldest timestamp from video buffer!");
1147 double oldestTrackerTimestamp(std::numeric_limits<double>::max());
1153 LOG_ERROR(
"Failed to get oldest timestamp from tracker buffer - there is no active tool!");
1160 LOG_WARNING(
"Unable to get timestamp from default tool tracker buffer");
1166 double oldestFieldDataTimestamp(std::numeric_limits<double>::max());
1174 LOG_WARNING(
"Unable to get timestamp from default field data buffer");
1179 double oldestTimestamp = std::min(std::min(oldestFieldDataTimestamp, oldestTrackerTimestamp), oldestVideoTimestamp);
1182 oldestVideoTimestamp = oldestTimestamp;
1186 oldestTrackerTimestamp = oldestTimestamp;
1190 oldestFieldDataTimestamp = oldestTimestamp;
1194 if (oldestVideoTimestamp < oldestTrackerTimestamp)
1200 LOG_ERROR(
"Failed to get video buffer item UID from time: " << std::fixed << oldestVideoTimestamp);
1203 if (oldestVideoTimestamp < oldestTrackerTimestamp)
1210 LOG_ERROR(
"Failed to get oldest timestamp: no overlap between tracking and video data");
1215 LOG_ERROR(
"Failed to get video buffer timestamp from UID: " << videoUid);
1218 if (oldestVideoTimestamp < oldestTrackerTimestamp)
1220 LOG_ERROR(
"Failed to get oldest timestamp: no overlap between tracking and video data");
1227 if (oldestVideoTimestamp < oldestFieldDataTimestamp)
1233 LOG_ERROR(
"Failed to get video buffer item UID from time: " << std::fixed << oldestVideoTimestamp);
1236 if (oldestVideoTimestamp < oldestFieldDataTimestamp)
1243 LOG_ERROR(
"Failed to get oldest timestamp: no overlap between field data and video data");
1248 LOG_ERROR(
"Failed to get video buffer timestamp from UID: " << videoUid);
1251 if (oldestVideoTimestamp < oldestFieldDataTimestamp)
1253 LOG_ERROR(
"Failed to get oldest timestamp: no overlap between field data and video data");
1259 ts = oldestVideoTimestamp;
1269 double latestVideoTimestamp(0);
1275 "Unable to get latest timestamp from video buffer!");
1278 double latestTrackerTimestamp(0);
1281 double latestCommonTrackerTimestamp = 0;
1282 bool mostRecentTrackerTimestampRetrieved =
false;
1288 LOG_ERROR(
"Invalid tool " << it->first);
1292 double latestTrackerTimestampForCurrentTool = 0;
1295 LOG_WARNING(
"Unable to get timestamp from " << it->first <<
" tool tracker buffer for time: " << latestTrackerTimestampForCurrentTool);
1298 if (!mostRecentTrackerTimestampRetrieved)
1301 latestCommonTrackerTimestamp = latestTrackerTimestampForCurrentTool;
1302 mostRecentTrackerTimestampRetrieved =
true;
1304 else if (latestTrackerTimestampForCurrentTool < latestCommonTrackerTimestamp)
1306 latestCommonTrackerTimestamp = latestTrackerTimestampForCurrentTool;
1310 if (!mostRecentTrackerTimestampRetrieved)
1312 LOG_ERROR(
"Failed to get most recent timestamp from all the tracker tools");
1320 LOG_ERROR(
"Failed to get most recent timestamp from tracker buffer - there is no active tool");
1327 LOG_ERROR(
"Failed to get tracker buffer item UID from time: " << std::fixed << latestCommonTrackerTimestamp);
1331 double latestTrackerTimestampForMasterTool = 0;
1335 LOG_WARNING(
"Unable to get timestamp from default tool tracker buffer with UID: " << uid);
1339 if (latestTrackerTimestampForMasterTool > latestCommonTrackerTimestamp)
1346 LOG_ERROR(
"Failed to get most recent timestamp: no time overlap between tracking tools");
1351 LOG_ERROR(
"Failed to get tracker buffer timestamp from UID: " << uid - 1);
1354 if (latestTrackerTimestampForMasterTool > latestCommonTrackerTimestamp)
1356 LOG_ERROR(
"Failed to get most recent timestamp: no time overlap between tracking tools data");
1361 latestTrackerTimestamp = latestTrackerTimestampForMasterTool;
1364 double latestFieldDataTimestamp(0);
1367 double latestCommonTimestamp(0);
1368 bool mostRecentSourceTimestampRetrieved(
false);
1372 if (aSource == NULL)
1374 LOG_ERROR(
"Invalid data source " << it->first);
1378 double latestTimestampForCurrentSource(0);
1381 LOG_WARNING(
"Unable to get timestamp from " << it->first <<
" field data buffer for time: " << latestTimestampForCurrentSource);
1384 if (!mostRecentSourceTimestampRetrieved)
1387 latestCommonTimestamp = latestTimestampForCurrentSource;
1388 mostRecentSourceTimestampRetrieved =
true;
1390 else if (latestTimestampForCurrentSource < latestCommonTimestamp)
1392 latestCommonTimestamp = latestTimestampForCurrentSource;
1396 if (!mostRecentSourceTimestampRetrieved)
1398 LOG_ERROR(
"Failed to get most recent timestamp from all the field data sources");
1402 latestFieldDataTimestamp = latestCommonTimestamp;
1407 latestVideoTimestamp = std::max(latestTrackerTimestamp, latestFieldDataTimestamp);
1412 latestTrackerTimestamp = std::max(latestVideoTimestamp, latestFieldDataTimestamp);
1417 latestFieldDataTimestamp = std::max(latestVideoTimestamp, latestTrackerTimestamp);;
1421 if (latestVideoTimestamp > latestTrackerTimestamp)
1425 static vtkIGSIOLogHelper logHelper(60.0, 500000);
1427 "Failed to get video buffer item UID from time: " << std::fixed << latestVideoTimestamp);
1429 "Failed to get video buffer timestamp from UID: " << videoUid);
1430 if (latestVideoTimestamp > latestTrackerTimestamp)
1437 LOG_ERROR(
"Failed to get most recent timestamp: no overlap between tracking and video data");
1442 LOG_ERROR(
"Failed to get video buffer timestamp from UID: " << videoUid);
1445 if (latestVideoTimestamp > latestTrackerTimestamp)
1447 LOG_ERROR(
"Failed to get most recent timestamp: no overlap between tracking and video data");
1454 if (latestVideoTimestamp > latestFieldDataTimestamp)
1459 "Failed to get video buffer item UID from time: " << std::fixed << latestVideoTimestamp);
1461 "Failed to get video buffer timestamp from UID: " << videoUid);
1462 if (latestVideoTimestamp > latestFieldDataTimestamp)
1469 LOG_ERROR(
"Failed to get most recent timestamp: no overlap between field and video data");
1474 LOG_ERROR(
"Failed to get video buffer timestamp from UID: " << videoUid);
1477 if (latestVideoTimestamp > latestFieldDataTimestamp)
1479 LOG_ERROR(
"Failed to get most recent timestamp: no overlap between field and video data");
1485 ts = latestVideoTimestamp;
1579 LOG_ERROR(
"Failed to get the timestamp master tool - there is no active tool");
1585 LOG_ERROR(
"Failed to get the timestamp master tool - the first active tool is invalid");
1596 int numberOfFrames = 0;
1612 numberOfFrames = abs((
int)(toItemUid - fromItemUid));
1619 LOG_ERROR(
"Failed to get number of frames between timestamps - there is no active tool!");
1635 numberOfFrames = abs((
int)(toItemUid - fromItemUid));
1653 numberOfFrames = abs((
int)(toItemUid - fromItemUid));
1656 return numberOfFrames + 1;
1667 return UNDEFINED_TIMESTAMP;
1669 double closestTimestamp = UNDEFINED_TIMESTAMP;
1672 return UNDEFINED_TIMESTAMP;
1674 return closestTimestamp;
1683 return UNDEFINED_TIMESTAMP;
1688 return UNDEFINED_TIMESTAMP;
1690 double closestTimestamp = UNDEFINED_TIMESTAMP;
1693 return UNDEFINED_TIMESTAMP;
1695 return closestTimestamp;
1704 return UNDEFINED_TIMESTAMP;
1706 double closestTimestamp = UNDEFINED_TIMESTAMP;
1709 return UNDEFINED_TIMESTAMP;
1711 return closestTimestamp;
1715 return UNDEFINED_TIMESTAMP;
1729 vtkImageData* resultImage = this->
BlankImage;
1737 LOG_DEBUG(
"No video data available yet, return blank frame");
1763 int* resultExtent = resultImage->GetExtent();
1788 output[it->first] = it->second;
1797 std::string tempValue;
1800 LOG_WARNING(
"Attribute: " << attributeId <<
" will be overwritten with value: " <<
value);
1810 #ifdef PLUS_RENDERING_ENABLED 1811 if (htmlReport == NULL)
1813 LOG_ERROR(
"Caller should define HTML report generator before report generation!");
1817 vtkSmartPointer<vtkTable> timestampReportTable = vtkSmartPointer<vtkTable>::New();
1824 int imageSize[2] = {800, 400};
1832 LOG_ERROR(
"Failed to get timestamp report table from video buffer!");
1840 std::string imageFilePath = htmlReport->
AddImageAutoFilename(std::string(deviceAndChannelName +
"VideoBufferTimestamps.png").c_str(),
"Video Data Acquisition Analysis");
1853 LOG_ERROR(
"Failed to get timestamp report table from tool '" << tool->GetId() <<
"' buffer!");
1857 reportText = std::string(
"Tracking data - ") + tool->GetId();
1859 std::string imageFilePath = htmlReport->
AddImageAutoFilename(std::string(deviceAndChannelName +
"-" + tool->GetId() +
"-TrackerBufferTimestamps.png").c_str(), reportText.c_str());
1875 LOG_ERROR(
"Failed to get timestamp report table from source '" << aSource->GetId() <<
"' buffer!");
1879 reportText = std::string(
"Field data - ") + aSource->GetId();
1881 std::string imageFilePath = htmlReport->
AddImageAutoFilename(std::string(deviceAndChannelName +
"-" + aSource->GetId() +
"-FieldDataBufferTimestamps.png").c_str(), reportText.c_str());
1892 LOG_WARNING(
"Cannot generate report when VTK_RENDERING_BACKEND is None!");
1904 if (
source->GetNumberOfItems() <= 0)
1909 source->GetLatestStreamBufferItem(&item);
1910 int dims[3] = {0, 0, 0};
1911 item.
GetFrame().GetImage()->GetDimensions(dims);
DataSourceContainer::const_iterator DataSourceContainerConstIterator
static const double SAMPLING_SKIPPING_MARGIN_SEC
virtual BufferItemUidType GetLatestItemUidInBuffer()
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *rfElement)
PlusStatus GetDataSource(const char *aSourceId, vtkPlusDataSource *&aSource)
static PlusStatus WriteTableToFile(vtkTable &table, const std::string &filename)
PlusStatus GetFieldDataSource(vtkPlusDataSource *&aSource, const std::string &sourceId)
ToolStatus GetStatus() const
virtual void AddText(const char *text, HEADINGS h, const char *style=NULL)
bool GetVideoEnabled() const
bool HasVideoSource() const
PlusStatus SetCustomAttribute(const std::string &attributeId, const std::string &value)
static vtkPlusRfProcessor * New()
std::string GetOutputPath(const std::string &subPath)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aChannelElement)
virtual void ShallowCopy(vtkDataObject *)
virtual double GetLocalTimeOffsetSec()
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *toolElement)
bool GetVideoDataAvailable()
DataSourceContainerIterator GetToolsStartIterator()
virtual ItemStatus GetStreamBufferItem(BufferItemUidType uid, StreamBufferItem *bufferItem)
static PlusStatus WriteLineChartToFile(const std::string &chartTitle, const std::string &yAxisText, vtkTable &inputTable, int xColumnIndex, int y1ColumnIndex, int y2ColumnIndex, int imageSize[2], const std::string &outputImageFilename)
PlusStatus GetCustomAttribute(const std::string &attributeId, std::string &output) const
PlusStatus GetTool(vtkPlusDataSource *&aTool, const std::string &toolSourceId)
PlusStatus RemoveTool(const std::string &toolSourceId)
CustomAttributeMap::const_iterator CustomAttributeMapConstIterator
StreamBufferItem BrightnessOutputTrackedFrame
virtual PlusStatus GetTrackedFrame(double timestamp, igsioTrackedFrame &trackedFrame, bool enableImageData=true)
PlusStatus GetBrightnessFrameSize(FrameSizeType &aDim)
virtual ~vtkPlusChannel(void)
DataSourceContainerConstIterator GetToolsEndConstIterator() const
DataSourceContainerIterator GetFieldDataSourcesStartIterator()
std::map< std::string, std::string > CustomAttributeMap
virtual std::string GetDeviceId() const
vtkImageData * GetBrightnessOutput()
virtual PlusStatus Clear()
bool GetTrackingDataAvailable()
vtkPlusDataSource * TimestampMasterTool
DataSourceContainerIterator GetToolsEndIterator()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *rfElement)
vtkPlusDevice * OwnerDevice
virtual bool GetLatestItemHasValidVideoData()
virtual vtkImageData * GetBrightnessScanConvertedImage()
DataSourceContainerConstIterator GetFieldDataSourcesStartConstIterator() const
virtual PlusStatus GetLatestTimestamp(double &aTimestamp) const
PlusStatus AddTool(vtkPlusDataSource *aTool)
DataSourceContainer Tools
static std::string DATA_SOURCE_TYPE_FIELDDATA_TAG
static vtkPlusConfig * GetInstance()
bool GetFieldDataEnabled() const
virtual PlusStatus SetRfFrame(vtkImageData *rfFrame, US_IMAGE_TYPE imageType)
static std::string DATA_SOURCE_TYPE_VIDEO_TAG
igsioFieldMapType GetFrameFieldMap()
virtual ItemStatus GetTimeStamp(BufferItemUidType uid, double ×tamp)
DataSourceContainerConstIterator GetFieldDataSourcesEndConstIterator() const
DataSourceContainerConstIterator GetToolsStartConstIterator() const
DataSourceContainer FieldDataSources
PlusStatus GetCustomAttributeMap(CustomAttributeMap &output) const
virtual BufferItemUidType GetOldestItemUidInBuffer()
virtual PlusStatus GetTimeStampReportTable(vtkTable *timeStampReportTable)
virtual void AddHorizontalLine()
bool GetFieldDataAvailable()
virtual PlusStatus GetMostRecentTimestamp(double &ts)
vtkStandardNewMacro(vtkPlusChannel)
PlusStatus RemoveFieldDataSource(const std::string &sourceId)
PlusStatus GetTrackedFrameList(double &aTimestampOfLastFrameAlreadyGot, vtkIGSIOTrackedFrameList *aTrackedFrameList, int aMaxNumberOfFramesToAdd)
PlusStatus GetTimestampMasterTool(vtkPlusDataSource *&aTool)
virtual int GetNumberOfFramesBetweenTimestamps(double aTimestampFrom, double aTimestampTo)
PlusStatus GetMatrix(vtkMatrix4x4 *outputMatrix)
virtual char * GetChannelId()
FrameSizeType BrightnessFrameSize
DataSourceContainer::iterator DataSourceContainerIterator
PlusStatus RemoveFieldDataSources()
igsioVideoFrame & GetFrame()
virtual ItemStatus GetLatestTimeStamp(double &latestTimestamp)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aChannelElement, bool RequireImageOrientationInChannelConfiguration)
vtkPlusDataSource * VideoSource
bool GetTrackingEnabled() const
const char const char * value
void SetVideoSource(vtkPlusDataSource *aSource)
static std::string DATA_SOURCE_TYPE_TOOL_TAG
PlusStatus GetToolByPortName(vtkPlusDataSource *&aTool, const std::string &portName)
virtual PlusStatus GetTrackedFrameListSampled(double &aTimestampOfLastFrameAlreadyGot, double &aTimestampOfNextFrameToBeAdded, vtkIGSIOTrackedFrameList *aTrackedFrameList, double aSamplingPeriodSec, double maxTimeLimitSec=-1)
virtual ItemStatus GetLatestStreamBufferItem(StreamBufferItem *bufferItem)
virtual void SetChannelId(const char *)
vtkImageData * BlankImage
virtual PlusStatus GetOldestTimestamp(double &ts)
vtkPlusRfProcessor * RfProcessor
bool SaveRfProcessingParameters
virtual ItemStatus GetStreamBufferItemFromTime(double time, StreamBufferItem *bufferItem, vtkPlusBuffer::DataItemTemporalInterpolationType interpolation)
virtual std::string AddImageAutoFilename(const char *filenamePostfix, const char *description, const int widthPx=0, const int heightPx=0)
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
static const char * GetRfProcessorTagName()
bool IsVideoSource3D() const
virtual double GetClosestTrackedFrameTimestampByTime(double time)
std::string GetToolReferenceFrameName() const
virtual ItemStatus GetItemUidFromTime(double time, BufferItemUidType &uid)
PlusStatus GetVideoSource(vtkPlusDataSource *&aVideoSource) const
PlusStatus GetVideoSource(const char *aSourceId, vtkPlusDataSource *&aVideoSource)
class for generating basic html tags
unsigned long long BufferItemUidType
void SetOwnerDevice(vtkPlusDevice *_arg)
virtual ItemStatus GetOldestTimeStamp(double &oldestTimestamp)
vtkPlusDevice * GetOwnerDevice() const
virtual PlusStatus GenerateDataAcquisitionReport(vtkPlusHTMLGenerator *htmlReport)
CustomAttributeMap CustomAttributes
virtual PlusStatus WriteCompactConfiguration(vtkXMLDataElement *toolElement)
DataSourceContainerIterator GetFieldDataSourcesEndIterator()
PlusStatus AddFieldDataSource(vtkPlusDataSource *aSource)
virtual int GetNumberOfItems()
double GetTimestamp(double localTimeOffsetSec)
virtual bool GetLatestItemHasValidFieldData()
virtual bool GetLatestItemHasValidTransformData()
Interface to a 3D positioning tool, video source, or generalized data stream.