/** extract information from the IGTLinkUSStatusMessage * and store locally. Also reset the old local info with * information from the probe in toolmanager. */ void VideoConnection::updateStatus(ProbeDefinitionPtr msg) { ToolPtr tool = mBackend->tracking()->getFirstProbe(); if (!tool || !tool->getProbe()) { //Don't throw away the ProbeDefinition. Save it until it can be used if (mUnusedProbeDefinitionVector.empty()) connect(mBackend->tracking().get(), &TrackingService::stateChanged, this, &VideoConnection::useUnusedProbeDefinitionSlot); mUnusedProbeDefinitionVector.push_back(msg); return; } ProbePtr probe = tool->getProbe(); // start with getting a valid data object from the probe, in order to keep // existing values (such as temporal calibration). // Note that the 'active' data is get while the 'uid' data is set. ProbeDefinition data = probe->getProbeDefinition(); data.setUid(msg->getUid()); data.setType(msg->getType()); data.setSector(msg->getDepthStart(), msg->getDepthEnd(), msg->getWidth()); data.setOrigin_p(msg->getOrigin_p()); data.setSize(msg->getSize()); data.setSpacing(msg->getSpacing()); data.setClipRect_p(msg->getClipRect_p()); data.setUseDigitalVideo(true); probe->setProbeDefinition(data); probe->setActiveStream(msg->getUid()); }
void VideoConnection::resetProbe() { ToolPtr tool = mBackend->tracking()->getFirstProbe(); if (!tool || !tool->getProbe()) return; ProbePtr probe = tool->getProbe(); if (probe) { ProbeDefinition data = probe->getProbeDefinition(); data.setUseDigitalVideo(false); probe->setProbeDefinition(data); } }
/**Create and return the structure that would have been read by UsReconstructFileReader, * if written from this object. * */ USReconstructInputData UsReconstructionFileMaker::getReconstructData(ImageDataContainerPtr imageData, std::vector<TimeInfo> imageTimestamps, TimedTransformMap trackerRecordedData, std::map<double, ToolPositionMetadata> trackerRecordedMetadata, std::map<double, ToolPositionMetadata> referenceRecordedMetadata, ToolPtr tool, QString streamUid, bool writeColor, Transform3D rMpr) { if(trackerRecordedData.empty()) reportWarning("No tracking data for writing to reconstruction file."); USReconstructInputData retval; retval.mFilename = mSessionDescription; // not saved yet - no filename retval.mUsRaw = USFrameData::create(mSessionDescription, imageData); retval.rMpr = rMpr; retval.mTrackerRecordedMetadata = trackerRecordedMetadata; retval.mReferenceRecordedMetadata = referenceRecordedMetadata; for (TimedTransformMap::iterator it = trackerRecordedData.begin(); it != trackerRecordedData.end(); ++it) { TimedPosition current; current.mTime = it->first; current.mTimeInfo.setAcquisitionTime(it->first); current.mPos = it->second; retval.mPositions.push_back(current); } std::vector<TimeInfo> fts = imageTimestamps; for (unsigned i=0; i<fts.size(); ++i) { TimedPosition current; current.mTimeInfo = fts[i]; current.mTime = current.mTimeInfo.getAcquisitionTime(); current.mPos = Transform3D::Identity(); // current.mPos = not written - will be found from track positions during reconstruction. retval.mFrames.push_back(current); } if (tool && tool->getProbe()) { retval.mProbeDefinition.setData(tool->getProbe()->getProbeDefinition(streamUid)); } if (tool) retval.mProbeUid = tool->getUid(); this->fillFramePositions(&retval); return retval; }
void PatientModelImplService::connectProbes() { ToolMap tools = mTrackingService->getTools(); for (ToolMap::const_iterator iter = tools.begin(); iter != tools.end(); ++iter) { ToolPtr tool = iter->second; ProbePtr probe = tool->getProbe(); if(tool->getProbe()) { mProbeTools[iter->first] = tool; connect(probe.get(), &Probe::videoSourceAdded, this, &PatientModelImplService::videoSourceAdded); } } }
VideoSourcePtr VideoImplService::getGuessForActiveVideoSource(VideoSourcePtr old) { if(old && old->getUid().contains("playback")) return old; QStringList nameFilters; nameFilters << "TissueAngio.fts" << "TissueFlow.fts" << "ScanConverted.fts"; // ask for playback stream: foreach(USAcquisitionVideoPlaybackPtr uSAcquisitionVideoPlayback,mUSAcquisitionVideoPlaybacks) { if (uSAcquisitionVideoPlayback->isActive() && nameFilters.contains(uSAcquisitionVideoPlayback->getType()) ) return uSAcquisitionVideoPlayback->getVideoSource(); } // ask for playback stream: foreach(USAcquisitionVideoPlaybackPtr uSAcquisitionVideoPlayback,mUSAcquisitionVideoPlaybacks) { if (uSAcquisitionVideoPlayback->isActive()) return uSAcquisitionVideoPlayback->getVideoSource(); } // ask for active stream in first probe: ToolPtr tool = mBackend->tracking()->getFirstProbe(); if (tool && tool->getProbe() && tool->getProbe()->getRTSource()) { // keep existing if present if (old) { if (tool->getProbe()->getAvailableVideoSources().count(old->getUid())) return old; } return tool->getProbe()->getRTSource(); } std::vector<VideoSourcePtr> allSources = this->getVideoSources(); // keep existing if present if (old) { if (std::count(allSources.begin(), allSources.end(), old)) return old; } // ask for anything if (!allSources.empty()) return allSources.front(); // give up: return empty return mEmptyVideoSource; }
std::vector<VideoSourcePtr> USAcquisition::getRecordingVideoSources(ToolPtr tool) { std::vector<VideoSourcePtr> retval; if (tool && tool->getProbe()) { ProbePtr probe = tool->getProbe(); QStringList sources = probe->getAvailableVideoSources(); for (unsigned i=0; i<sources.size(); ++i) retval.push_back(probe->getRTSource(sources[i])); } else { retval = this->getServices()->video()->getVideoSources(); } return retval; }
ToolPtr PatientModelImplService::getProbeTool(QString videoSourceUid) { for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter) { ToolPtr tool = iter->second; ProbePtr probe = tool->getProbe(); if(probe && probe->getAvailableVideoSources().contains(videoSourceUid)) return tool; } reportWarning("Found no probe for stream" + videoSourceUid); return ToolPtr(); }
/** Imbue probe with all stream and probe info from grabber. * * Call when active probe is changed or when streaming config is changed (new streams, new probeDefinition) * * Find the active probe, then insert all current streams into that probe. * */ void VideoConnection::connectVideoToProbe() { ToolPtr tool = mBackend->tracking()->getFirstProbe(); if (!tool) return; ProbePtr probe = tool->getProbe(); if (!probe) return; for (unsigned i=0; i<mSources.size(); ++i) probe->setRTSource(mSources[i]); }
void VideoConnection::onDisconnected() { mClient = NULL; mThread = NULL; // because this method listens to thread::finished this->resetProbe(); this->stopAllSources(); for (unsigned i=0; i<mSources.size(); ++i) mSources[i]->setInput(ImagePtr()); ToolPtr tool = mBackend->tracking()->getFirstProbe(); if (tool && tool->getProbe()) this->removeSourceFromProbe(tool); mSources.clear(); mStreamerInterface.reset(); emit connected(false); emit videoSourcesChanged(); }
void VideoConnection::removeSourceFromProbe(ToolPtr tool) { ProbePtr probe = tool->getProbe(); for (unsigned i=0; i<mSources.size(); ++i) probe->removeRTSource(mSources[i]); }