An object of this class represents the interface to the MicronTracker. The methods of this class are calling the c-functions which are provided by the MTC-library. If the MicronTracker is not in use, which means the CMake-variable "MITK_USE_MICRON_TRACKER" is set to OFF, this class is replaced by a stub class called "ClaronInterfaceStub". More...
#include <mitkClaronInterface.h>
Public Types | |
typedef ClaronInterface | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
typedef ClaronInterface | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
void | Initialize (std::string calibrationDir, std::string toolFilesDir) |
Initialization of claroninterface. | |
bool | StartTracking () |
Opens the connection to the device and makes it ready to track tools. | |
bool | StopTracking () |
Clears all resources. After this method have been called the system isn't ready to track any longer. | |
std::vector< claronToolHandle > | GetAllActiveTools () |
std::vector< double > | GetTipPosition (claronToolHandle c) |
std::vector< double > | GetTipQuaternions (claronToolHandle c) |
std::vector< double > | GetPosition (claronToolHandle c) |
std::vector< double > | GetQuaternions (claronToolHandle c) |
const char * | GetName (claronToolHandle c) |
void | GrabFrame () |
Grabs a frame from the camera. | |
bool | IsTracking () |
bool | IsMicronTrackerInstalled () |
virtual const char * | GetClassName () const |
void | Initialize (std::string calibrationDir, std::string toolFilesDir) |
Initialization of claroninterface. | |
bool | StartTracking () |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
bool | StopTracking () |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
std::vector< claronToolHandle > | GetAllActiveTools () |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
std::vector< double > | GetTipPosition (claronToolHandle c) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
std::vector< double > | GetTipQuaternions (claronToolHandle c) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
std::vector< double > | GetPosition (claronToolHandle c) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
std::vector< double > | GetQuaternions (claronToolHandle c) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
const char * | GetName (claronToolHandle c) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
void | GrabFrame () |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker. | |
bool | IsMicronTrackerInstalled () |
Static Public Member Functions | |
static Pointer | New () |
static Pointer | New () |
Protected Member Functions | |
ClaronInterface () | |
standard constructor | |
~ClaronInterface () | |
standard destructor | |
ClaronInterface () | |
standard constructor | |
~ClaronInterface () | |
standard destructor | |
Protected Attributes | |
bool | isTracking |
Variable is true if the device is tracking at the moment, false if not. | |
char | calibrationDir [512] |
Variable which holds the directory which should contain the file BumbleBee_6400420.calib. This directory is needed by the MTC library. | |
char | markerDir [512] |
Variable which holds a directory with some tool files in it. All this tools are trackable when the path is given to the MTC library. | |
mtHandle | IdentifiedMarkers |
mtHandle | PoseXf |
mtHandle | CurrCamera |
mtHandle | IdentifyingCamera |
An object of this class represents the interface to the MicronTracker. The methods of this class are calling the c-functions which are provided by the MTC-library. If the MicronTracker is not in use, which means the CMake-variable "MITK_USE_MICRON_TRACKER" is set to OFF, this class is replaced by a stub class called "ClaronInterfaceStub".
An object of this class represents the interface to the MicronTracker. Normally the methods of this class are calling the c-functions which are provided by the MTC-library. But in this case the MicronTracker is not installed and so we only have stubs here. These stubs send error messages when you try to call the methods.
Documentation:
Definition at line 44 of file mitkClaronInterface.h.
typedef itk::SmartPointer<const Self> mitk::ClaronInterface::ConstPointer |
Definition at line 48 of file mitkClaronInterface.h.
typedef itk::SmartPointer<const Self> mitk::ClaronInterface::ConstPointer |
Definition at line 47 of file mitkClaronInterfaceStub.h.
typedef itk::SmartPointer<Self> mitk::ClaronInterface::Pointer |
Definition at line 48 of file mitkClaronInterface.h.
typedef itk::SmartPointer<Self> mitk::ClaronInterface::Pointer |
Definition at line 47 of file mitkClaronInterfaceStub.h.
Definition at line 47 of file mitkClaronInterfaceStub.h.
Definition at line 48 of file mitkClaronInterface.h.
typedef itk::Object mitk::ClaronInterface::Superclass |
Definition at line 47 of file mitkClaronInterfaceStub.h.
typedef itk::Object mitk::ClaronInterface::Superclass |
Definition at line 48 of file mitkClaronInterface.h.
mitk::ClaronInterface::ClaronInterface | ( | ) | [protected] |
standard constructor
Definition at line 24 of file mitkClaronInterface.cpp.
References calibrationDir, isTracking, and markerDir.
{ isTracking = false; sprintf(calibrationDir,"No calibration dir set yet"); sprintf(markerDir,"No marker dir set yet"); }
mitk::ClaronInterface::~ClaronInterface | ( | ) | [protected] |
mitk::ClaronInterface::ClaronInterface | ( | ) | [protected] |
standard constructor
mitk::ClaronInterface::~ClaronInterface | ( | ) | [protected] |
standard destructor
std::vector< mitk::claronToolHandle > mitk::ClaronInterface::GetAllActiveTools | ( | ) |
Definition at line 120 of file mitkClaronInterface.cpp.
References MTC.
{ //Set returnvalue std::vector<claronToolHandle> returnValue; //Here, MTC internally maintains the measurement results. //Those results can be accessed until the next call to Markers_ProcessFrame, when they //are updated to reflect the next frame's content. //First, we will obtain the collection of the markers that were identified. MTC( Markers_IdentifiedMarkersGet(NULL, IdentifiedMarkers) ); //Now we iterate on the identified markers and add them to the returnvalue for (int j=1; j<=Collection_Count(IdentifiedMarkers); j++) { // Obtain the marker's handle, and use it to obtain the pose in the current camera's space // using our Xform3D object, PoseXf. mtHandle Marker = Collection_Int(IdentifiedMarkers, j); returnValue.push_back(Marker); } return returnValue; }
std::vector<claronToolHandle> mitk::ClaronInterface::GetAllActiveTools | ( | ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
virtual const char* mitk::ClaronInterface::GetClassName | ( | ) | const [virtual] |
virtual const char* mitk::ClaronInterface::GetClassName | ( | ) | const [virtual] |
const char * mitk::ClaronInterface::GetName | ( | claronToolHandle | c ) |
c | The handle of the tool, which name should be given back. |
Definition at line 275 of file mitkClaronInterface.cpp.
References MTC.
{ char MarkerName[MT_MAX_STRING_LENGTH]; MTC( Marker_NameGet(c, MarkerName, MT_MAX_STRING_LENGTH, 0) ); std::string* returnValue = new std::string(MarkerName); return returnValue->c_str(); }
const char* mitk::ClaronInterface::GetName | ( | claronToolHandle | c ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
std::vector< double > mitk::ClaronInterface::GetPosition | ( | claronToolHandle | c ) |
Definition at line 175 of file mitkClaronInterface.cpp.
References MTC.
{ std::vector<double> returnValue; double Position[3]; MTC( Marker_Marker2CameraXfGet (c, CurrCamera, PoseXf, &IdentifyingCamera) ); MTC( Xform3D_ShiftGet(PoseXf, Position) ); // Here we have to negate the X- and Y-coordinates because of a bug of the // MTC-library. returnValue.push_back(-Position[0]); returnValue.push_back(-Position[1]); returnValue.push_back(Position[2]); return returnValue; }
std::vector<double> mitk::ClaronInterface::GetPosition | ( | claronToolHandle | c ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
std::vector< double > mitk::ClaronInterface::GetQuaternions | ( | claronToolHandle | c ) |
Definition at line 237 of file mitkClaronInterface.cpp.
References MTC, and QuadProgPP::sqrt().
{ std::vector<double> returnValue; double Quarternions[4]; MTC( Marker_Marker2CameraXfGet (c, CurrCamera, PoseXf, &IdentifyingCamera) ); MTC( Xform3D_RotQuaternionsGet(PoseXf, Quarternions) ); //here we have to compensate a bug in the MTC-lib. (difficult to understand) mitk::Quaternion claronQuaternion; //note: claron quarternion has different order than the mitk quarternion claronQuaternion[3] = Quarternions[0]; claronQuaternion[0] = Quarternions[1]; claronQuaternion[1] = Quarternions[2]; claronQuaternion[2] = Quarternions[3]; // Here we have to make a -90°-turn around the Y-axis because of a bug of the // MTC-library. mitk::Quaternion minusNinetyDegreeY; minusNinetyDegreeY[3] = sqrt(2.0)/2.0; minusNinetyDegreeY[0] = 0; minusNinetyDegreeY[1] = -1.0/(sqrt(2.0)); minusNinetyDegreeY[2] = 0; //calculate the result... mitk::Quaternion erg = (minusNinetyDegreeY*claronQuaternion); returnValue.push_back(erg[3]); returnValue.push_back(erg[0]); returnValue.push_back(erg[1]); returnValue.push_back(erg[2]); return returnValue; }
std::vector<double> mitk::ClaronInterface::GetQuaternions | ( | claronToolHandle | c ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
std::vector<double> mitk::ClaronInterface::GetTipPosition | ( | claronToolHandle | c ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
std::vector< double > mitk::ClaronInterface::GetTipPosition | ( | mitk::claronToolHandle | c ) |
Definition at line 148 of file mitkClaronInterface.cpp.
References MTC.
{ std::vector<double> returnValue; double Position[3]; mtHandle t2m = Xform3D_New(); // tooltip to marker xform handle mtHandle t2c = Xform3D_New(); // tooltip to camera xform handle mtHandle m2c = Xform3D_New(); // marker to camera xform handle //Get m2c MTC( Marker_Marker2CameraXfGet (c, CurrCamera, m2c, &IdentifyingCamera) ); //Get t2m MTC( Marker_Tooltip2MarkerXfGet (c, t2m )); //Transform both to t2c MTC(Xform3D_Concatenate(t2m,m2c,t2c)); //Get position MTC( Xform3D_ShiftGet(t2c, Position) ); // Here we have to negate the X- and Y-coordinates because of a bug of the // MTC-library. returnValue.push_back(-Position[0]); returnValue.push_back(-Position[1]); returnValue.push_back(Position[2]); return returnValue; }
std::vector< double > mitk::ClaronInterface::GetTipQuaternions | ( | claronToolHandle | c ) |
Definition at line 192 of file mitkClaronInterface.cpp.
References MTC, and QuadProgPP::sqrt().
{ std::vector<double> returnValue; mtHandle t2m = Xform3D_New(); // tooltip to marker xform handle mtHandle t2c = Xform3D_New(); // tooltip to camera xform handle mtHandle m2c = Xform3D_New(); // marker to camera xform handle //Get m2c MTC( Marker_Marker2CameraXfGet (c, CurrCamera, m2c, &IdentifyingCamera) ); //Get t2m MTC( Marker_Tooltip2MarkerXfGet (c, t2m )); //Transform both to t2c MTC(Xform3D_Concatenate(t2m,m2c,t2c)); //get the Claron-Quaternion double Quarternions[4]; MTC( Xform3D_RotQuaternionsGet(t2c, Quarternions) ); mitk::Quaternion claronQuaternion; //note: claron quarternion has different order than the mitk quarternion claronQuaternion[3] = Quarternions[0]; claronQuaternion[0] = Quarternions[1]; claronQuaternion[1] = Quarternions[2]; claronQuaternion[2] = Quarternions[3]; // Here we have to make a -90°-turn around the Y-axis because of a bug of the // MTC-library. mitk::Quaternion minusNinetyDegreeY; minusNinetyDegreeY[3] = sqrt(2.0)/2.0; minusNinetyDegreeY[0] = 0; minusNinetyDegreeY[1] = -1.0/(sqrt(2.0)); minusNinetyDegreeY[2] = 0; //calculate the result... mitk::Quaternion erg = (minusNinetyDegreeY*claronQuaternion); returnValue.push_back(erg[3]); returnValue.push_back(erg[0]); returnValue.push_back(erg[1]); returnValue.push_back(erg[2]); return returnValue; }
std::vector<double> mitk::ClaronInterface::GetTipQuaternions | ( | claronToolHandle | c ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
void mitk::ClaronInterface::GrabFrame | ( | ) |
Grabs a frame from the camera.
Definition at line 142 of file mitkClaronInterface.cpp.
References MTC.
void mitk::ClaronInterface::GrabFrame | ( | ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
void mitk::ClaronInterface::Initialize | ( | std::string | calibrationDir, |
std::string | toolFilesDir | ||
) |
Initialization of claroninterface.
calibrationDir | The directory where the device can find the camera calibration file. |
toolFilesDir | The directory for the tool files. |
void mitk::ClaronInterface::Initialize | ( | std::string | calibrationDir, |
std::string | toolFilesDir | ||
) |
Initialization of claroninterface.
calibrationDir | The directory where the device can find the camera calibration file. |
toolFilesDir | The directory for the tool files. |
Definition at line 36 of file mitkClaronInterface.cpp.
{ sprintf(this->calibrationDir, calibrationDir.c_str()); sprintf(this->markerDir,toolFilesDir.c_str()); this->IdentifiedMarkers = 0; this->PoseXf = 0; this->CurrCamera = 0; this->IdentifyingCamera = 0; }
bool mitk::ClaronInterface::IsMicronTrackerInstalled | ( | ) |
bool mitk::ClaronInterface::IsMicronTrackerInstalled | ( | ) |
Definition at line 288 of file mitkClaronInterface.cpp.
{ return true; }
bool mitk::ClaronInterface::IsTracking | ( | ) |
Definition at line 283 of file mitkClaronInterface.cpp.
{ return this->isTracking; }
static Pointer mitk::ClaronInterface::New | ( | ) | [static] |
static Pointer mitk::ClaronInterface::New | ( | ) | [static] |
Referenced by mitkClaronInterfaceTest(), and mitk::ClaronTrackingDevice::OpenConnection().
bool mitk::ClaronInterface::StartTracking | ( | ) |
Opens the connection to the device and makes it ready to track tools.
Definition at line 47 of file mitkClaronInterface.cpp.
References MTC.
{ isTracking = false; MTC( Cameras_AttachAvailableCameras(calibrationDir) ); //Connect to camera if (Cameras_Count() < 1) { printf("No camera found!\n"); return false; } try { //Step 1: initialize cameras MTC(Cameras_HistogramEqualizeImagesSet(true)); //set the histogram equalizing MTC( Cameras_ItemGet(0, &CurrCamera) ); //Obtain a handle to the first/only camera in the array //Step 2: Load the marker templates MTC( Markers_LoadTemplates(markerDir) ); //Path to directory where the marker templates are printf("Loaded %d marker templates\n",Markers_TemplatesCount()); //Step 3: Wait for 20 frames for (int i=0; i<20; i++)//the first 20 frames are auto-adjustment frames, we ignore them { MTC( Cameras_GrabFrame(NULL) ); //Grab a frame (all cameras together) MTC( Markers_ProcessFrame(NULL) ); //Proces the frame(s) to obtain measurements } //Step 4: Initialize IdentifiedMarkers and PoseXf IdentifiedMarkers = Collection_New(); PoseXf = Xform3D_New(); //now we are tracking... /* MTHome is not in use. The following code has to be activated if you want to use MTHome! //Initialize MTHome if ( getMTHome (MTHome, sizeof(MTHome)) < 0 ) { // No Environment printf("MTHome environment variable is not set!\n"); }*/ } catch(...) { Cameras_Detach(); printf(" Error while connecting MicronTracker!\n -------------------------------"); return false; } isTracking = true; return true; }
bool mitk::ClaronInterface::StartTracking | ( | ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
bool mitk::ClaronInterface::StopTracking | ( | ) |
This is only a stub, please switch the cmake variable USE_MICRON_TRACKER to on if you want to use the Microntracker.
bool mitk::ClaronInterface::StopTracking | ( | ) |
Clears all resources. After this method have been called the system isn't ready to track any longer.
Definition at line 99 of file mitkClaronInterface.cpp.
{ if (isTracking) { //free up the resources Collection_Free(IdentifiedMarkers); Xform3D_Free(PoseXf); //stop the camera Cameras_Detach(); //now tracking is stopped isTracking = false; return true; } else { return false; } }
char mitk::ClaronInterface::calibrationDir[512] [protected] |
Variable which holds the directory which should contain the file BumbleBee_6400420.calib. This directory is needed by the MTC library.
Definition at line 132 of file mitkClaronInterface.h.
Referenced by ClaronInterface().
mtHandle mitk::ClaronInterface::CurrCamera [protected] |
Definition at line 139 of file mitkClaronInterface.h.
mtHandle mitk::ClaronInterface::IdentifiedMarkers [protected] |
Definition at line 137 of file mitkClaronInterface.h.
mtHandle mitk::ClaronInterface::IdentifyingCamera [protected] |
Definition at line 140 of file mitkClaronInterface.h.
bool mitk::ClaronInterface::isTracking [protected] |
Variable is true if the device is tracking at the moment, false if not.
Definition at line 129 of file mitkClaronInterface.h.
Referenced by ClaronInterface().
char mitk::ClaronInterface::markerDir[512] [protected] |
Variable which holds a directory with some tool files in it. All this tools are trackable when the path is given to the MTC library.
Definition at line 134 of file mitkClaronInterface.h.
Referenced by ClaronInterface().
mtHandle mitk::ClaronInterface::PoseXf [protected] |
Definition at line 138 of file mitkClaronInterface.h.