<commit_before>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center, 
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without 
even the implied warranty of MERCHANTABILITY or FITNESS FOR 
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "mitkUSVideoDevice.h"


mitk::USVideoDevice::USVideoDevice(int videoDeviceNumber, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = false;
  m_DeviceID = videoDeviceNumber;
}

mitk::USVideoDevice::USVideoDevice(std::string videoFilePath, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = true;
  m_FilePath = videoFilePath;
}

mitk::USVideoDevice::USVideoDevice(int videoDeviceNumber, mitk::USImageMetadata::Pointer metadata) : mitk::USDevice(metadata)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = false;
  m_DeviceID = videoDeviceNumber;
}

mitk::USVideoDevice::USVideoDevice(std::string videoFilePath, mitk::USImageMetadata::Pointer metadata) : mitk::USDevice(metadata)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = true;
  m_FilePath = videoFilePath;
}

mitk::USVideoDevice::~USVideoDevice()
{
  
}

std::string mitk::USVideoDevice::GetDeviceClass(){
  return "org.mitk.modules.us.USVideoDevice";
}


bool mitk::USVideoDevice::OnConnection()
{
  m_Source = mitk::USImageVideoSource::New();
  if (m_SourceIsFile){
    m_Source->SetVideoFileInput(m_FilePath);
  } else {
     m_Source->SetCameraInput(m_DeviceID);
  }
  return true;
}

/**
* \brief Is called during the disconnection process.
*  Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.
*/
bool mitk::USVideoDevice::OnDisconnection()
{
    // TODO Implement Disconnection Behaviour
  return true;
}

/**
* \brief Is called during the activation process. After this method is finsihed, the device should be generating images
*/
bool mitk::USVideoDevice::OnActivation()
{
    // TODO Implement Activation Behaviour
  return true;
}  


/**
* \brief Is called during the deactivation process. After a call to this method the device should still be connected, but not producing images anymore.
*/
void mitk::USVideoDevice::OnDeactivation()
{
    // TODO Implement Deactivation Behaviour

}

void mitk::USVideoDevice::GenerateData()
{
  mitk::USImage::Pointer result;
  result = m_Source->GetNextImage();
  
  // Set Metadata
  result->SetMetadata(this->m_Metadata);
  // Set Output
  this->SetNthOutput(0, result);
}<commit_msg>USVideoDevices now apply their calibration Data to the image<commit_after>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center, 
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without 
even the implied warranty of MERCHANTABILITY or FITNESS FOR 
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "mitkUSVideoDevice.h"


mitk::USVideoDevice::USVideoDevice(int videoDeviceNumber, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = false;
  m_DeviceID = videoDeviceNumber;
}

mitk::USVideoDevice::USVideoDevice(std::string videoFilePath, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = true;
  m_FilePath = videoFilePath;
}

mitk::USVideoDevice::USVideoDevice(int videoDeviceNumber, mitk::USImageMetadata::Pointer metadata) : mitk::USDevice(metadata)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = false;
  m_DeviceID = videoDeviceNumber;
}

mitk::USVideoDevice::USVideoDevice(std::string videoFilePath, mitk::USImageMetadata::Pointer metadata) : mitk::USDevice(metadata)
{
  this->SetNumberOfInputs(1);
  this->SetNumberOfOutputs(1);
  m_SourceIsFile = true;
  m_FilePath = videoFilePath;
}

mitk::USVideoDevice::~USVideoDevice()
{
  
}

std::string mitk::USVideoDevice::GetDeviceClass(){
  return "org.mitk.modules.us.USVideoDevice";
}


bool mitk::USVideoDevice::OnConnection()
{
  m_Source = mitk::USImageVideoSource::New();
  if (m_SourceIsFile){
    m_Source->SetVideoFileInput(m_FilePath);
  } else {
     m_Source->SetCameraInput(m_DeviceID);
  }
  return true;
}

bool mitk::USVideoDevice::OnDisconnection()
{
    // TODO Implement Disconnection Behaviour
  return true;
}


bool mitk::USVideoDevice::OnActivation()
{
    // TODO Implement Activation Behaviour
  return true;
}  


/**
* \brief Is called during the deactivation process. After a call to this method the device should still be connected, but not producing images anymore.
*/
void mitk::USVideoDevice::OnDeactivation()
{
    // TODO Implement Deactivation Behaviour

}

void mitk::USVideoDevice::GenerateData()
{
  mitk::USImage::Pointer result;
  result = m_Source->GetNextImage();
  
  // Set Metadata
  result->SetMetadata(this->m_Metadata);
  //Apply Transformation
  this->ApplyCalibration(result);
  // Set Output
  this->SetNthOutput(0, result);
}
{'fraction_non_alphanumeric': 0.1553398058252427, 'fraction_numerical': 0.0031206657420249652, 'mean_word_length': 5.867857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1675839', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1720, 'n_words': 405}