Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
Medical Imaging Interaction Toolkit
mitkUSDevice.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkUSDevice.h"
14 #include "mitkImageReadAccessor.h"
15 
16 // US Control Interfaces
20 
21 // Microservices
22 #include <usGetModuleContext.h>
23 #include <usModule.h>
24 #include <usServiceProperties.h>
25 #include <usModuleContext.h>
26 
28 {
29  static mitk::USDevice::PropertyKeys propertyKeys;
30  return propertyKeys;
31 }
32 
34 {
35  MITK_INFO << "Return Crop Area L:" << m_CropArea.cropLeft
36  << " R:" << m_CropArea.cropRight << " T:" << m_CropArea.cropTop
37  << " B:" << m_CropArea.cropBottom;
38  return m_CropArea;
39 }
40 
42 {
43  return m_ImageVector.size();
44 }
45 
46 mitk::USDevice::USDevice(std::string manufacturer, std::string model)
47  : mitk::ImageSource(),
48  m_FreezeBarrier(nullptr),
49  m_FreezeMutex(),
50  m_MultiThreader(itk::MultiThreader::New()),
51  m_ImageMutex(itk::FastMutexLock::New()),
52  m_ThreadID(-1),
53  m_ImageVector(),
54  m_Spacing(),
55  m_IGTLServer(nullptr),
56  m_IGTLMessageProvider(nullptr),
57  m_ImageToIGTLMsgFilter(nullptr),
58  m_IsFreezed(false),
63  m_Manufacturer(manufacturer),
64  m_Name(model),
65  m_Comment(),
66  m_SpawnAcquireThread(true),
67  m_UnregisteringStarted(false)
68 {
69  USImageCropArea empty;
70  empty.cropBottom = 0;
71  empty.cropTop = 0;
72  empty.cropLeft = 0;
73  empty.cropRight = 0;
74  this->m_CropArea = empty;
75 
76  // set number of outputs
77  this->SetNumberOfIndexedOutputs(m_NumberOfOutputs);
78 
79  // create a new output
81  this->SetNthOutput(0, newOutput);
82 }
83 
84 mitk::USDevice::USDevice(mitk::USImageMetadata::Pointer metadata)
85  : mitk::ImageSource(),
86  m_FreezeBarrier(nullptr),
87  m_FreezeMutex(),
88  m_MultiThreader(itk::MultiThreader::New()),
89  m_ImageMutex(itk::FastMutexLock::New()),
90  m_ThreadID(-1),
91  m_ImageVector(),
92  m_Spacing(),
93  m_IGTLServer(nullptr),
94  m_IGTLMessageProvider(nullptr),
95  m_ImageToIGTLMsgFilter(nullptr),
96  m_IsFreezed(false),
101  m_SpawnAcquireThread(true),
102  m_UnregisteringStarted(false)
103 {
104  m_Manufacturer = metadata->GetDeviceManufacturer();
105  m_Name = metadata->GetDeviceModel();
106  m_Comment = metadata->GetDeviceComment();
107 
108  USImageCropArea empty;
109  empty.cropBottom = 0;
110  empty.cropTop = 0;
111  empty.cropLeft = 0;
112  empty.cropRight = 0;
113  this->m_CropArea = empty;
114 
115  // set number of outputs
116  this->SetNumberOfIndexedOutputs(m_NumberOfOutputs);
117 
118  // create a new output
120  this->SetNthOutput(0, newOutput);
121 }
122 
124 {
125  if (m_ThreadID >= 0)
126  {
127  m_MultiThreader->TerminateThread(m_ThreadID);
128  }
129 
130  // make sure that the us device is not registered at the micro service
131  // anymore after it is destructed
132  this->UnregisterOnService();
133 }
134 
135 mitk::USAbstractControlInterface::Pointer
137 {
138  MITK_INFO << "Custom control interface does not exist for this object.";
139  return nullptr;
140 }
141 
142 mitk::USControlInterfaceBMode::Pointer
144 {
145  MITK_INFO << "Control interface BMode does not exist for this object.";
146  return nullptr;
147 }
148 
149 mitk::USControlInterfaceProbes::Pointer
151 {
152  MITK_INFO << "Control interface Probes does not exist for this object.";
153  return nullptr;
154 }
155 
156 mitk::USControlInterfaceDoppler::Pointer
158 {
159  MITK_INFO << "Control interface Doppler does not exist for this object.";
160  return nullptr;
161 }
162 
163 void mitk::USDevice::SetManufacturer(std::string manufacturer)
164 {
165  m_Manufacturer = manufacturer;
167  {
168  this->UpdateServiceProperty(
169  mitk::USDevice::GetPropertyKeys().US_PROPKEY_MANUFACTURER,
170  manufacturer);
171  }
172 }
173 
174 void mitk::USDevice::SetName(std::string name)
175 {
176  m_Name = name;
178  {
179  this->UpdateServiceProperty(
180  mitk::USDevice::GetPropertyKeys().US_PROPKEY_NAME, name);
181  }
182 }
183 
184 void mitk::USDevice::SetComment(std::string comment)
185 {
186  m_Comment = comment;
188  {
189  this->UpdateServiceProperty(
190  mitk::USDevice::GetPropertyKeys().US_PROPKEY_COMMENT, comment);
191  }
192 }
193 
195 {
197 
198  us::ServiceProperties props;
199 
200  props[propertyKeys.US_PROPKEY_ISCONNECTED] =
201  this->GetIsConnected() ? "true" : "false";
202  props[propertyKeys.US_PROPKEY_ISACTIVE] =
203  this->GetIsActive() ? "true" : "false";
204 
205  props[propertyKeys.US_PROPKEY_LABEL] = this->GetServicePropertyLabel();
206 
207  // get identifier of selected probe if there is one selected
208  mitk::USControlInterfaceProbes::Pointer probesControls =
210  if (probesControls.IsNotNull() && probesControls->GetIsActive())
211  {
212  mitk::USProbe::Pointer probe = probesControls->GetSelectedProbe();
213  if (probe.IsNotNull())
214  {
215  props[propertyKeys.US_PROPKEY_PROBES_SELECTED] = probe->GetName();
216  }
217  }
218 
219  props[propertyKeys.US_PROPKEY_CLASS] = GetDeviceClass();
220  props[propertyKeys.US_PROPKEY_MANUFACTURER] = m_Manufacturer;
221  props[propertyKeys.US_PROPKEY_NAME] = m_Name;
222  props[propertyKeys.US_PROPKEY_COMMENT] = m_Comment;
223 
224  m_ServiceProperties = props;
225 
226  return props;
227 }
228 
230 {
231  // unregister on micro service
232  if (m_ServiceRegistration && !m_UnregisteringStarted)
233  {
234  // make sure that unregister is not started a second
235  // time due to a callback during unregister for example
236  m_UnregisteringStarted = true;
239  }
240 }
241 
243 {
244  if (!this->OnInitialization())
245  {
246  return false;
247  }
248 
250 
251  // Get Context and Module
252  us::ModuleContext* context = us::GetModuleContext();
254 
255  m_ServiceRegistration = context->RegisterService(this, props);
256 
257  return true;
258 }
259 
261 {
262  MITK_DEBUG << "mitk::USDevice::Connect() called";
263 
264  if (this->GetIsConnected())
265  {
266  MITK_INFO("mitkUSDevice") << "Tried to connect an ultrasound device that "
267  "was already connected. Ignoring call...";
268  return true;
269  }
270 
271  if (!this->GetIsInitialized())
272  {
273  MITK_ERROR("mitkUSDevice")
274  << "Cannot connect device if it is not in initialized state.";
275  return false;
276  }
277 
278  // Prepare connection, fail if this fails.
279  if (!this->OnConnection())
280  {
281  return false;
282  }
283 
284  // Update state
286 
287  this->UpdateServiceProperty(
288  mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISCONNECTED, true);
289  return true;
290 }
291 
293 {
294  this->m_MultiThreader->SpawnThread(this->ConnectThread, this);
295 }
296 
298 {
299  if (!GetIsConnected())
300  {
301  MITK_WARN << "Tried to disconnect an ultrasound device that was not "
302  "connected. Ignoring call...";
303  return false;
304  }
305  // Prepare connection, fail if this fails.
306  if (!this->OnDisconnection())
307  return false;
308 
309  // Update state
311 
312  this->UpdateServiceProperty(
313  mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISCONNECTED, false);
314 
315  return true;
316 }
317 
319 {
320  if (!this->GetIsConnected())
321  {
322  MITK_INFO("mitkUSDevice")
323  << "Cannot activate device if it is not in connected state.";
324  return true;
325  }
326 
327  if (OnActivation())
328  {
330 
331  m_FreezeBarrier = itk::ConditionVariable::New();
332 
333  // spawn thread for aquire images if us device is active
334  if (m_SpawnAcquireThread)
335  {
336  this->m_ThreadID =
337  this->m_MultiThreader->SpawnThread(this->Acquire, this);
338  }
339 
340  this->UpdateServiceProperty(
341  mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE, true);
342  this->UpdateServiceProperty(
343  mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL,
344  this->GetServicePropertyLabel());
345  // initialize the b mode control properties of the micro service
346  mitk::USControlInterfaceBMode::Pointer bmodeControls =
347  this->GetControlInterfaceBMode();
348  if (bmodeControls.IsNotNull())
349  {
350  bmodeControls->Initialize();
351  }
352  }
353 
354  this->ProvideViaOIGTL();
355 
356  return m_DeviceState == State_Activated;
357 }
358 
360 {
361  // create a new OpenIGTLink Server
362  if (m_IGTLServer.IsNull())
363  m_IGTLServer = mitk::IGTLServer::New(true);
364 
365  m_IGTLServer->SetName(this->GetName());
366 
367  // create a new OpenIGTLink Device source
368  if (m_IGTLMessageProvider.IsNull())
370 
371  // set the OpenIGTLink server as the source for the device source
372  m_IGTLMessageProvider->SetIGTLDevice(m_IGTLServer);
373 
374  // register the provider so that it can be configured with the IGTL manager
375  // plugin. This could be hardcoded but now I already have the fancy plugin.
376  m_IGTLMessageProvider->RegisterAsMicroservice();
377 
379  m_ImageToIGTLMsgFilter->ConnectTo(this);
380 
381  // set the name of this filter to identify it easier
382  m_ImageToIGTLMsgFilter->SetName(this->GetName());
383 
384  // register this filter as micro service. The message provider looks for
385  // provided IGTLMessageSources, once it found this microservice and someone
386  // requested this data type then the provider will connect with this filter
387  // automatically.
388  m_ImageToIGTLMsgFilter->RegisterAsMicroservice();
389 }
390 
392 {
393  if (!this->GetIsActive())
394  {
395  MITK_WARN("mitkUSDevice")
396  << "Cannot deactivate a device which is not activae.";
397  return;
398  }
399 
400  if (!OnDeactivation())
401  {
402  return;
403  }
404 
405  DisableOIGTL();
407 
408  this->UpdateServiceProperty(
409  mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE, false);
410  this->UpdateServiceProperty(
411  mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL,
412  this->GetServicePropertyLabel());
413 }
414 
416 {
417  // TODO: This seems not to be enough cleanup to catch all cases. For example, if the device is disconnected
418  // from the OIGTL GUI, this won't get cleaned up correctly.
419  m_IGTLServer->CloseConnection();
420  m_IGTLMessageProvider->UnRegisterMicroservice();
421  m_ImageToIGTLMsgFilter->UnRegisterMicroservice();
422 }
423 
425 {
426  if (!this->GetIsActive())
427  {
428  MITK_WARN("mitkUSDevice")
429  << "Cannot freeze or unfreeze if device is not active.";
430  return;
431  }
432 
433  this->OnFreeze(freeze);
434 
435  if (freeze)
436  {
437  m_IsFreezed = true;
438  }
439  else
440  {
441  m_IsFreezed = false;
442 
443  // wake up the image acquisition thread
444  m_FreezeBarrier->Signal();
445  }
446 }
447 
449 {
450  /*
451  if (!this->GetIsActive())
452  {
453  MITK_WARN("mitkUSDevice")("mitkUSTelemedDevice")
454  << "Cannot get freeze state if the hardware interface is not ready. "
455  "Returning false...";
456  return false;
457  }*/
458 
459  return m_IsFreezed;
460 }
461 
462 void mitk::USDevice::PushFilter(AbstractOpenCVImageFilter::Pointer filter)
463 {
464  mitk::USImageSource::Pointer imageSource = this->GetUSImageSource();
465  if (imageSource.IsNull())
466  {
467  MITK_ERROR << "ImageSource must not be null when pushing a filter.";
468  mitkThrow() << "ImageSource must not be null when pushing a filter.";
469  }
470 
471  imageSource->PushFilter(filter);
472 }
473 
475  AbstractOpenCVImageFilter::Pointer filter)
476 {
477  mitk::USImageSource::Pointer imageSource = this->GetUSImageSource();
478  if (imageSource.IsNull())
479  {
480  MITK_ERROR << "ImageSource must not be null when pushing a filter.";
481  mitkThrow() << "ImageSource must not be null when pushing a filter.";
482  }
483 
484  if (!imageSource->GetIsFilterInThePipeline(filter))
485  {
486  imageSource->PushFilter(filter);
487  }
488 }
489 
490 bool mitk::USDevice::RemoveFilter(AbstractOpenCVImageFilter::Pointer filter)
491 {
492  mitk::USImageSource::Pointer imageSource = this->GetUSImageSource();
493  if (imageSource.IsNull())
494  {
495  MITK_ERROR << "ImageSource must not be null when pushing a filter.";
496  mitkThrow() << "ImageSource must not be null when removing a filter.";
497  }
498 
499  return imageSource->RemoveFilter(filter);
500 }
501 
502 void mitk::USDevice::UpdateServiceProperty(std::string key, std::string value)
503 {
504  m_ServiceProperties[key] = value;
506 
507  // send event to notify listeners about the changed property
508  m_PropertyChangedMessage(key, value);
509 }
510 
511 void mitk::USDevice::UpdateServiceProperty(std::string key, double value)
512 {
513  std::stringstream stream;
514  stream << value;
515  this->UpdateServiceProperty(key, stream.str());
516 }
517 
518 void mitk::USDevice::UpdateServiceProperty(std::string key, bool value)
519 {
520  this->UpdateServiceProperty(
521  key, value ? std::string("true") : std::string("false"));
522 }
523 
570 {
571  std::vector<mitk::Image::Pointer> image = this->GetUSImageSource()->GetNextImage();
572  m_ImageMutex->Lock();
573  this->SetImageVector(image);
574  m_ImageMutex->Unlock();
575 }
576 
577 //########### GETTER & SETTER ##################//
578 
580 {
582 }
583 
585 
587 {
588  return m_DeviceState == State_Connected;
589 }
590 
591 std::string mitk::USDevice::GetDeviceManufacturer() { return m_Manufacturer; }
592 
593 std::string mitk::USDevice::GetDeviceModel() { return m_Name; }
594 
595 std::string mitk::USDevice::GetDeviceComment() { return m_Comment; }
596 
597 void mitk::USDevice::SetSpacing(double xSpacing, double ySpacing)
598 {
599  m_Spacing[0] = xSpacing;
600  m_Spacing[1] = ySpacing;
601  m_Spacing[2] = 1;
602 
603 
604  if( m_ImageVector.size() > 0 )
605  {
606  for( size_t index = 0; index < m_ImageVector.size(); ++index )
607  {
608  auto& image = m_ImageVector[index];
609  if( image.IsNotNull() && image->IsInitialized() )
610  {
611  image->GetGeometry()->SetSpacing(m_Spacing);
612  }
613  }
614  this->Modified();
615  }
616  MITK_INFO << "Spacing: " << m_Spacing;
617 }
618 
620 {
621  m_ImageMutex->Lock();
622 
623  for (unsigned int i = 0; i < m_ImageVector.size() && i < this->GetNumberOfIndexedOutputs(); ++i)
624  {
625  auto& image = m_ImageVector[i];
626  if (image.IsNull() || !image->IsInitialized())
627  {
628  // skip image
629  }
630  else
631  {
632  mitk::Image::Pointer output = this->GetOutput(i);
633 
634  if (!output->IsInitialized() ||
635  output->GetDimension(0) != image->GetDimension(0) ||
636  output->GetDimension(1) != image->GetDimension(1) ||
637  output->GetDimension(2) != image->GetDimension(2) ||
638  output->GetPixelType() != image->GetPixelType())
639  {
640  output->Initialize(image->GetPixelType(), image->GetDimension(),
641  image->GetDimensions());
642  }
643 
644  // copy contents of the given image into the member variable
645  mitk::ImageReadAccessor inputReadAccessor(image);
646  output->SetImportVolume(inputReadAccessor.GetData());
647  output->SetGeometry(image->GetGeometry());
648  }
649  }
650  m_ImageMutex->Unlock();
651 };
652 
654 {
655  std::string isActive;
656  if (this->GetIsActive())
657  {
658  isActive = " (Active)";
659  }
660  else
661  {
662  isActive = " (Inactive)";
663  }
664  // e.g.: Zonare MyLab5 (Active)
665  return m_Manufacturer + " " + m_Name + isActive;
666 }
667 
668 ITK_THREAD_RETURN_TYPE mitk::USDevice::Acquire(void* pInfoStruct)
669 {
670  /* extract this pointer from Thread Info structure */
671  struct itk::MultiThreader::ThreadInfoStruct* pInfo =
672  (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
673  mitk::USDevice* device = (mitk::USDevice*)pInfo->UserData;
674  while (device->GetIsActive())
675  {
676  // lock this thread when ultrasound device is freezed
677  if (device->m_IsFreezed)
678  {
679  itk::SimpleMutexLock* mutex = &(device->m_FreezeMutex);
680  mutex->Lock();
681 
682  if (device->m_FreezeBarrier.IsNotNull())
683  {
684  device->m_FreezeBarrier->Wait(mutex);
685  }
686  }
687  device->GrabImage();
688  }
689  return ITK_THREAD_RETURN_VALUE;
690 }
691 
692 ITK_THREAD_RETURN_TYPE mitk::USDevice::ConnectThread(void* pInfoStruct)
693 {
694  /* extract this pointer from Thread Info structure */
695  struct itk::MultiThreader::ThreadInfoStruct* pInfo =
696  (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
697  mitk::USDevice* device = (mitk::USDevice*)pInfo->UserData;
698 
699  device->Connect();
700 
701  return ITK_THREAD_RETURN_VALUE;
702 }
703 
704 
705 void mitk::USDevice::ProbeChanged(std::string probename)
706 {
707  this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_PROBES_SELECTED, probename);
708 }
709 
711 {
712  this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DEPTH, depth);
713 }
virtual itk::SmartPointer< USControlInterfaceBMode > GetControlInterfaceBMode()
Default getter for the b mode control interface. Has to be implemented in a subclass if a b mode cont...
Superclass of all classes generating Images (instances of class Image) as output. ...
bool Activate()
Activates this device. After the activation process, the device will start to produce images...
A device holds information about it&#39;s model, make and the connected probes. It is the common super cl...
Definition: mitkUSDevice.h:73
void UpdateServiceProperty(std::string key, std::string value)
Given property is updated in the device micro service. This method is mainly for being used by the co...
virtual USImageSource::Pointer GetUSImageSource()=0
static ITK_THREAD_RETURN_TYPE Acquire(void *pInfoStruct)
std::string GetDeviceComment()
Deprecated -> use GetCommend() instead.
#define MITK_INFO
Definition: mitkLogMacros.h:18
mitk::IGTLMessageProvider::Pointer m_IGTLMessageProvider
Definition: mitkUSDevice.h:403
~USDevice() override
#define MITK_ERROR
Definition: mitkLogMacros.h:20
void PushFilterIfNotPushedBefore(AbstractOpenCVImageFilter::Pointer filter)
virtual bool OnInitialization()=0
Is called during the initialization process. Override this method in a subclass to handle the actual ...
USImageCropArea m_CropArea
Definition: mitkUSDevice.h:411
const std::string US_PROPKEY_LABEL
Definition: mitkUSDevice.h:103
us::ServiceProperties ConstructServiceProperties()
This Method constructs the service properties which can later be used to register the object with the...
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
static Pointer New()
Method for creation through the object factory.
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::USDevice::PropertyKeys GetPropertyKeys()
const std::string US_PROPKEY_ISCONNECTED
Definition: mitkUSDevice.h:104
void DisableOIGTL()
Deregisters the microservices for OpenIGTLink.
bool Connect()
Connects this device. A connected device is ready to deliver images (i.e. be Activated). A Connected Device can be active. A disconnected Device cannot be active. Internally calls onConnect and then registers the device with the service. A device usually should override the OnConnection() method, but never the Connect() method, since this will possibly exclude the device from normal service management. The exact flow of events is: 0. Check if the device is already connected. If yes, return true anyway, but don&#39;t do anything.
bool GetIsConnected()
True, if the device is currently ready to start transmitting image data or is already transmitting im...
itk::ConditionVariable::Pointer m_FreezeBarrier
Definition: mitkUSDevice.h:368
std::string GetDeviceManufacturer()
Deprecated -> use GetManufacturer() instead.
virtual bool OnDisconnection()=0
Is called during the disconnection process. Override this method in a subclass to handle the actual d...
virtual bool OnDeactivation()=0
Is called during the deactivation process. After a call to this method the device should still be con...
mitk::IGTLServer::Pointer m_IGTLServer
Definition: mitkUSDevice.h:402
mitk::USDevice::USImageCropArea GetCropArea()
void ProbeChanged(std::string probename)
To be called when the used probe changed. Will update the service properties.
virtual itk::SmartPointer< USControlInterfaceDoppler > GetControlInterfaceDoppler()
Default getter for the doppler control interface. Has to be implemented in a subclass if a doppler co...
void DepthChanged(double depth)
To be called when the scanning depth of the probe changed. Will update the service properties...
virtual std::string GetName()
const std::string US_PROPKEY_CLASS
Definition: mitkUSDevice.h:106
void SetComment(std::string comment)
#define MITK_WARN
Definition: mitkLogMacros.h:19
mitk::ImageToIGTLMessageFilter::Pointer m_ImageToIGTLMsgFilter
Definition: mitkUSDevice.h:404
std::string GetDeviceModel()
Deprecated -> use GetName() instead.
These constants are used in conjunction with Microservices. The constants aren&#39;t defined as static me...
Definition: mitkUSDevice.h:97
int m_ThreadID
ID of the started thread.
Definition: mitkUSDevice.h:372
mitk::Vector3D m_Spacing
Definition: mitkUSDevice.h:389
static Pointer New()
void SetManufacturer(std::string manufacturer)
#define mitkThrow()
unsigned int GetSizeOfImageVector()
itk::MultiThreader::Pointer m_MultiThreader
itk::MultiThreader used for thread handling
Definition: mitkUSDevice.h:370
virtual void SetIsFreezed(bool freeze)
Can toggle if ultrasound image is currently updated or freezed.
const std::string US_PROPKEY_PROBES_SELECTED
Definition: mitkUSDevice.h:108
USDevice(std::string manufacturer, std::string model)
Enforces minimal Metadata to be set.
us::ServiceRegistration< Self > m_ServiceRegistration
The device&#39;s ServiceRegistration object that allows to modify it&#39;s Microservice registraton details...
Definition: mitkUSDevice.h:513
void ConnectAsynchron()
us::ServiceProperties m_ServiceProperties
Properties of the device&#39;s Microservice.
Definition: mitkUSDevice.h:508
virtual void SetImageVector(std::vector< mitk::Image::Pointer > vec)
Definition: mitkUSDevice.h:374
bool Initialize()
Changes device state to mitk::USDevice::State_Initialized. During initialization the virtual method m...
mitk::Image::Pointer image
virtual void SetSpacing(double xSpacing, double ySpacing)
static Pointer New()
void UnregisterOnService()
Remove this device from the micro service.
const std::string US_PROPKEY_MANUFACTURER
Definition: mitkUSDevice.h:100
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
unsigned int m_NumberOfOutputs
Definition: mitkUSDevice.h:503
void SetName(std::string name)
std::vector< mitk::Image::Pointer > m_ImageVector
Definition: mitkUSDevice.h:386
virtual bool OnConnection()=0
Is called during the connection process. Override this method in a subclass to handle the actual conn...
DeviceStates m_DeviceState
Definition: mitkUSDevice.h:408
itk::SimpleMutexLock m_FreezeMutex
Definition: mitkUSDevice.h:369
virtual bool GetIsFreezed()
void Deactivate()
Deactivates this device. After the deactivation process, the device will no longer produce images...
OutputType * GetOutput()
Get the output data of this image source object.
void GenerateData() override
Grabs the next frame from the Video input. This method is called internally, whenever Update() is inv...
void SetProperties(const ServiceProperties &properties)
virtual void OnFreeze(bool)
Called when mitk::USDevice::SetIsFreezed() is called. Subclasses can overwrite this method to do addi...
Definition: mitkUSDevice.h:480
const std::string US_PROPKEY_ISACTIVE
Definition: mitkUSDevice.h:105
bool GetIsInitialized()
True, if the device object is created and initialized, false otherwise.
const std::string US_PROPKEY_NAME
Definition: mitkUSDevice.h:101
itk::FastMutexLock::Pointer m_ImageMutex
mutex for images provided by the image source
Definition: mitkUSDevice.h:371
static ITK_THREAD_RETURN_TYPE ConnectThread(void *pInfoStruct)
ImageReadAccessor class to get locked read access for a particular image part.
void PushFilter(AbstractOpenCVImageFilter::Pointer filter)
bool GetIsActive()
True, if the device is currently generating image data, false otherwise.
void ProvideViaOIGTL()
Registers an OpenIGTLink device as a microservice so that we can send the images of this device via t...
virtual bool OnActivation()=0
Is called during the activation process. After this method is finished, the device should be generati...
virtual itk::SmartPointer< USAbstractControlInterface > GetControlInterfaceCustom()
Default getter for the custom control interface. Has to be implemented in a subclass if a custom cont...
bool Disconnect()
Works analogously to mitk::USDevice::Connect(). Don&#39;t override this Method, but onDisconnection inste...
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
const std::string US_PROPKEY_COMMENT
Definition: mitkUSDevice.h:102
bool RemoveFilter(AbstractOpenCVImageFilter::Pointer filter)
virtual std::string GetDeviceClass()=0
Returns the Class of the Device. This Method must be reimplemented by every Inheriting Class...
const void * GetData() const
Gives const access to the data.
std::string GetServicePropertyLabel()
virtual itk::SmartPointer< USControlInterfaceProbes > GetControlInterfaceProbes()
Default getter for the probes control interface. Has to be implemented in a subclass if a probes cont...