16#include <usModuleContext.h>
17#include <usGetModuleContext.h>
19#include <usModuleResource.h>
20#include <usModuleResourceStream.h>
28 device->SetProperty(
"CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics));
31 us::ModuleContext* context = us::GetModuleContext();
32 us::ServiceProperties deviceProps;
34 m_DeviceRegistrations.insert(std::make_pair(device.GetPointer(), context->RegisterService(device.GetPointer(),deviceProps)));
40 std::map<ToFCameraDevice*,us::ServiceRegistration<ToFCameraDevice> >::iterator i = m_DeviceRegistrations.find(device.GetPointer());
41 if (i == m_DeviceRegistrations.end())
return;
43 i->second.Unregister();
44 m_DeviceRegistrations.erase(i);
46 m_Devices.erase(std::remove(m_Devices.begin(), m_Devices.end(), device), m_Devices.end());
51 return m_Devices.size();
56 us::ModuleResource resource = GetIntrinsicsResource();
57 if (! resource.IsValid())
59 MITK_WARN <<
"Could not load resource '" << resource.GetName() <<
"'. CameraIntrinsics are invalid!";
63 us::ModuleResourceStream resStream(resource);
64 std::string resString(std::istreambuf_iterator<char>(resStream), {});
67 tinyxml2::XMLDocument xmlDocument;
68 xmlDocument.Parse(resString.c_str());
71 auto* element = xmlDocument.FirstChildElement();
72 mitk::CameraIntrinsics::Pointer intrinsics = mitk::CameraIntrinsics::New();
73 intrinsics->FromXML(element);
80 us::Module* module = us::GetModuleContext()->GetModule();
81 return module->GetResource("CalibrationFiles/Default_Parameters.xml");
82 MITK_WARN <<
"Loaded Default CameraIntrinsics. Overwrite AbstractToFDeviceFactory::GetIntrinsicsResource() if you want to define your own.";
ToFCameraDevice::Pointer ConnectToFDevice()
ConnectToFDevice Use this method to connect a device.
std::string GetCurrentDeviceName() override
GetCurrentDeviceName Get the human readable name of the current device. A factory can produce many de...
virtual us::ModuleResource GetIntrinsicsResource()
Returns the ModuleResource that contains a xml definition of the CameraIntrinsics.
CameraIntrinsics::Pointer GetCameraIntrinsics()
Returns the CameraIntrinsics for the cameras created by this factory.
void DisconnectToFDevice(const ToFCameraDevice::Pointer &device)
DisconnectToFDevice Use this method to disconnect a device.
std::map< ToFCameraDevice *, us::ServiceRegistration< ToFCameraDevice > > m_DeviceRegistrations
m_DeviceRegistrations A map containing all the pairs of device registration numbers and devices.
std::vector< ToFCameraDevice::Pointer > m_Devices
m_Devices A list (vector) containing all connected devices of the respective factory.
size_t GetNumberOfDevices()
GetNumberOfDevices Get the number of devices produced by this factory. This function will return the ...
virtual ToFCameraDevice::Pointer CreateToFCameraDevice()=0
CreateToFCameraDevice Create a new device of the respective factory. E.g. a "KinectFactory" creates a...