8 #include "PlusConfigure.h" 26 static const std::string ADD_RECORDING_DEVICE_CMD =
"AddRecordingDevice";
33 this->SetName(ADD_RECORDING_DEVICE_CMD);
45 this->SetName(ADD_RECORDING_DEVICE_CMD);
52 cmdNames.push_back(ADD_RECORDING_DEVICE_CMD);
59 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, ADD_RECORDING_DEVICE_CMD))
61 desc += ADD_RECORDING_DEVICE_CMD;
62 desc +=
": Add a virtual capture device with inputs defined by metadata \"InputChannels\".";
70 igtl::MessageBase::MetaDataMap::iterator it = this->
MetaData.find(
"InputChannels");
71 if (it == end(this->
MetaData) || it->second.second.empty())
73 LOG_ERROR(
"Input channels not defined or empty, nothing to record.");
74 this->
QueueCommandResponse(
PLUS_FAIL,
"Input channels not defined or empty.",
"Please specify \"InputChannels\" metadata argument as a \"Separator\" separated list.");
83 separator = this->
MetaData[
"Separator"].second[0];
86 std::string inputChannels = it->second.second;
87 std::vector<std::string> tokens = igsioCommon::SplitStringIntoTokens(inputChannels, separator,
false);
88 if (tokens.size() == 0)
90 LOG_ERROR(
"Input channels ill defined, nothing to record.");
91 this->
QueueCommandResponse(
PLUS_FAIL,
"Input channels ill defined.",
"Please specify \"InputChannels\" metadata argument as a \"Separator\" separated list.");
95 std::vector<vtkPlusChannel*> channels;
96 for (std::vector<std::string>::iterator it = begin(tokens); it != end(tokens); ++it)
101 LOG_ERROR(
"Input channel " << *it <<
" not found. Aborting.");
102 this->
QueueCommandResponse(
PLUS_FAIL,
"Input channel " + *it +
" not found.",
"Please use \"RequestIds\" command to retrieve list of current channels.");
109 std::string deviceId;
115 std::string candidateName =
"VirtualCapure[" + igsioCommon::ToString<int>(counter++) +
"]";
119 deviceId = candidateName;
126 deviceId = this->
MetaData[
"Id"].second;
132 LOG_ERROR(
"Unable to create device of type \"VirtualCapture\" with ID: " << deviceId);
141 std::string baseFilename(
"GeneratedVirtualCapture.nrrd");
144 baseFilename = this->
MetaData[
"BaseFilename"].second;
145 if (vtksys::SystemTools::GetFilenameExtension(baseFilename) ==
"")
147 baseFilename = baseFilename +
".nrrd";
152 bool enableFileCompression(
true);
153 if (this->
MetaData.find(
"EnableFileCompression") == end(this->
MetaData) || this->
MetaData[
"EnableFileCompression"].second.empty())
155 enableFileCompression = igsioCommon::IsEqualInsensitive(this->
MetaData[
"EnableFileCompression"].second,
"TRUE");
160 bool enableCapturingOnStart(
true);
161 if (this->
MetaData.find(
"EnableCapturingOnStart") == end(this->
MetaData) || this->
MetaData[
"EnableCapturingOnStart"].second.empty())
163 enableCapturingOnStart = igsioCommon::IsEqualInsensitive(this->
MetaData[
"EnableCapturingOnStart"].second,
"TRUE");
167 if (this->
MetaData.find(
"RequestedFrameRate") == end(this->
MetaData) || this->
MetaData[
"RequestedFrameRate"].second.empty())
169 std::stringstream ss;
170 ss << this->
MetaData[
"RequestedFrameRate"].second;
173 int requestedFrameRate(0);
174 ss >> requestedFrameRate;
180 int frameBufferSize(0);
181 if (this->
MetaData.find(
"FrameBufferSize") == end(this->
MetaData) || this->
MetaData[
"FrameBufferSize"].second.empty())
183 std::stringstream ss;
184 ss << this->
MetaData[
"FrameBufferSize"].second;
187 ss >> frameBufferSize;
193 for (std::vector<vtkPlusChannel*>::iterator it = begin(channels); it != end(channels); ++it)
200 LOG_ERROR(
"Unable to add capture device.");
PlusStatus AddInputChannel(vtkPlusChannel *aChannel)
Abstract interface for tracker and video devices.
virtual PlusStatus Execute()
virtual void GetCommandNames(std::list< std::string > &cmdNames)
void SetEnableFileCompression(bool aFileCompression)
virtual void SetBaseFilename(std::string)
igtl::MessageBase::MetaDataMap MetaData
vtkStandardNewMacro(vtkPlusAddRecordingDeviceCommand)
virtual void SetFrameBufferSize(unsigned int)
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
void SetEnableCapturing(bool aValue)
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
virtual void SetRequestedFrameRate(double)
void SetNameToAddRecordingDevice()
vtkPlusAddRecordingDeviceCommand()
This command adds a virtual capture device with the attached arguments as input channels.
virtual std::string GetDescription(const std::string &commandName)
virtual ~vtkPlusAddRecordingDeviceCommand()