54 m_Source = mitk::USImageVideoSource::New();
55 m_ControlInterfaceCustom = mitk::USVideoDeviceCustomControls::New(
this);
57 this->SetNumberOfIndexedOutputs(1);
61 this->SetNthOutput(0, this->MakeOutput(0));
71 return "org.mitk.modules.us.USVideoDevice";
76 return m_ControlInterfaceCustom.GetPointer();
88 m_Source->SetVideoFileInput(m_FilePath);
91 m_Source->SetCameraInput(m_DeviceID);
99 if (m_DeviceState == State_Activated) this->Deactivate();
101 m_Source->ReleaseInput();
109 if (!m_Source->GetIsReady())
111 MITK_WARN(
"mitkUSDevice")(
"mitkUSVideoDevice") <<
"Could not activate us video device. Check if video grabber is configured correctly.";
115 MITK_INFO <<
"Activated UsVideoDevice!";
127 Superclass::GenerateData();
129 if( m_ImageVector.size() == 0 || this->GetNumberOfIndexedOutputs() == 0 )
135 auto& image = m_ImageVector[0];
136 if( image.IsNotNull() && image->IsInitialized() && m_CurrentProbe.IsNotNull() )
139 image->GetGeometry()->SetSpacing(m_CurrentProbe->GetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth()));
140 this->GetOutput(0)->SetGeometry(image->GetGeometry());
142 m_ImageMutex.unlock();
147 if (m_DeviceState == State_Activated) { this->Deactivate(); }
148 if (m_DeviceState == State_Connected) { this->Disconnect(); }
155 return m_Source.GetPointer();
160 if (m_Probes.empty())
162 MITK_INFO <<
"No probes exist for this USVideDevice. Empty vector is returned";
174 if (m_CurrentProbe.IsNotNull())
176 return m_CurrentProbe;
186 for (std::vector<mitk::USProbe::Pointer>::iterator it = m_Probes.begin(); it != m_Probes.end(); it++)
188 if (name.compare((*it)->GetName()) == 0)
191 MITK_INFO <<
"No probe with given name " << name <<
" was found.";
197 for (std::vector<mitk::USProbe::Pointer>::iterator it = m_Probes.begin(); it != m_Probes.end(); it++)
199 if (name.compare((*it)->GetName()) == 0)
205 MITK_INFO <<
"No Probe with given name " << name <<
" was found";
210 m_Probes.push_back(probe);
215 return m_SourceIsFile;
220 if( m_Probes.size() == 0 )
222 std::string name =
"default";
223 mitk::USProbe::Pointer defaultProbe = mitk::USProbe::New( name );
224 m_Probes.push_back( defaultProbe );
227 m_CurrentProbe = m_Probes.at(0);
228 MITK_INFO <<
"SetDefaultProbeAsCurrentProbe()";
229 this->ProbeChanged( m_CurrentProbe->GetName() );
234 m_CurrentProbe = this->GetProbeByName( probename );
235 MITK_INFO <<
"SetCurrentProbe() " << probename;
240 mitk::Vector3D spacing;
241 spacing[0] = xSpacing;
242 spacing[1] = ySpacing;
244 MITK_INFO <<
"Spacing: " << spacing;
246 if( m_CurrentProbe.IsNotNull() )
248 m_CurrentProbe->SetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth(), spacing);
252 MITK_WARN <<
"Cannot set spacing. Current ultrasound probe not set.";
A device holds information about it's model, make and the connected probes. It is the common super cl...
void UnregisterOnService()
Remove this device from the micro service.
bool OnDisconnection() override
Is called during the disconnection process. Returns true if successful and false if unsuccessful....
itk::SmartPointer< USAbstractControlInterface > GetControlInterfaceCustom() override
bool OnDeactivation() override
Is called during the deactivation process. After a call to this method the device should still be con...
void DeleteAllProbes() override
Cleans the std::vector containing all configured probes.
mitk::USProbe::Pointer GetProbeByName(std::string name) override
get the probe by its name Returns a pointer to the probe identified by the given name....
~USVideoDevice() override
bool m_SourceIsFile
True, if this source plays back a file, false if it recieves data from a device.
std::vector< mitk::USProbe::Pointer > GetAllProbes() override
Return all probes for this USVideoDevice or an empty vector it no probes were set Returns a std::vect...
void GenerateData() override
Grabs the next frame from the Video input. This method is called internally, whenever Update() is inv...
void SetSpacing(double xSpacing, double ySpacing) override
Sets the given spacing of the current depth of the current probe.
void UnregisterOnService()
Remove this device from the micro service. This method is public for mitk::USVideoDevice,...
void RemoveProbeByName(std::string name) override
Removes the Probe with the given name.
bool OnInitialization() override
Is called during the initialization process. Returns true if successful and false if unsuccessful....
mitk::USProbe::Pointer GetCurrentProbe() override
Return current active probe for this USVideoDevice Returns a pointer to the probe that is currently i...
int m_DeviceID
The device id to connect to. Undefined, if m_SourceIsFile == true;.
bool OnConnection() override
Is called during the connection process. Returns true if successful and false if unsuccessful....
std::string GetDeviceClass() override
void AddNewProbe(mitk::USProbe::Pointer probe) override
adds a new probe to the device
void Init()
Initializes common properties for all constructors.
USImageSource::Pointer GetUSImageSource() override
USVideoDevice(int videoDeviceNumber, std::string manufacturer, std::string model)
Creates a new device that will deliver USImages taken from a video device. under windows,...
static std::string GetDeviceClassStatic()
void SetCurrentProbe(std::string probename) override
Sets the probe with the given name as current probe if the named probe exists.
std::string m_FilePath
The Filepath id to connect to. Undefined, if m_SourceIsFile == false;.
bool OnActivation() override
Is called during the activation process. After this method is finsihed, the device should be generati...
bool GetIsSourceFile()
True, if this Device plays back a file, false if it recieves data from a device.
void SetDefaultProbeAsCurrentProbe() override
Sets the first existing probe or the default probe of the video device as the current probe of it.