27 sprintf(
markerDir,
"No marker dir set yet");
37 sprintf(this->calibrationDir, calibrationDir.c_str());
38 sprintf(this->markerDir,toolFilesDir.c_str());
39 this->IdentifiedMarkers = 0;
42 this->IdentifyingCamera = 0;
49 MTC( Cameras_AttachAvailableCameras(calibrationDir) );
50 if (Cameras_Count() < 1)
52 printf(
"No camera found!\n");
59 MTC(Cameras_HistogramEqualizeImagesSet(
true));
60 MTC( Cameras_ItemGet(0, &CurrCamera) );
64 MTC( Markers_LoadTemplates(markerDir) );
65 printf(
"Loaded %d marker templates\n",Markers_TemplatesCount());
68 for (
int i=0; i<20; i++)
70 MTC( Cameras_GrabFrame(NULL) );
71 MTC( Markers_ProcessFrame(NULL) );
75 IdentifiedMarkers = Collection_New();
76 PoseXf = Xform3D_New();
91 printf(
" Error while connecting MicronTracker!\n -------------------------------");
104 Collection_Free(IdentifiedMarkers);
105 Xform3D_Free(PoseXf);
123 std::vector<claronToolHandle> returnValue;
129 MTC( Markers_IdentifiedMarkersGet(NULL, IdentifiedMarkers) );
132 for (
int j=1; j<=Collection_Count(IdentifiedMarkers); j++)
136 mtHandle Marker = Collection_Int(IdentifiedMarkers, j);
137 returnValue.push_back(Marker);
144 MTC( Cameras_GrabFrame(NULL) );
145 MTC( Markers_ProcessFrame(NULL) );
150 std::vector<double> returnValue;
157 MTC( Marker_Marker2CameraXfGet (c, CurrCamera, m2c, &IdentifyingCamera) );
159 MTC( Marker_Tooltip2MarkerXfGet (c, t2m ));
161 MTC(Xform3D_Concatenate(t2m,m2c,t2c));
164 MTC( Xform3D_ShiftGet(t2c, Position) );
168 returnValue.push_back(-Position[0]);
169 returnValue.push_back(-Position[1]);
170 returnValue.push_back(Position[2]);
177 std::vector<double> returnValue;
179 MTC( Marker_Marker2CameraXfGet (c, CurrCamera, PoseXf, &IdentifyingCamera) );
180 MTC( Xform3D_ShiftGet(PoseXf, Position) );
184 returnValue.push_back(-Position[0]);
185 returnValue.push_back(-Position[1]);
186 returnValue.push_back(Position[2]);
194 std::vector<double> returnValue;
201 MTC( Marker_Marker2CameraXfGet (c, CurrCamera, m2c, &IdentifyingCamera) );
203 MTC( Marker_Tooltip2MarkerXfGet (c, t2m ));
205 MTC(Xform3D_Concatenate(t2m,m2c,t2c));
208 double Quarternions[4];
209 MTC( Xform3D_RotQuaternionsGet(t2c, Quarternions) );
213 claronQuaternion[3] = Quarternions[0];
214 claronQuaternion[0] = Quarternions[1];
215 claronQuaternion[1] = Quarternions[2];
216 claronQuaternion[2] = Quarternions[3];
221 minusNinetyDegreeY[3] = sqrt(2.0)/2.0;
222 minusNinetyDegreeY[0] = 0;
223 minusNinetyDegreeY[1] = -1.0/(sqrt(2.0));
224 minusNinetyDegreeY[2] = 0;
229 returnValue.push_back(erg[3]);
230 returnValue.push_back(erg[0]);
231 returnValue.push_back(erg[1]);
232 returnValue.push_back(erg[2]);
239 std::vector<double> returnValue;
241 double Quarternions[4];
242 MTC( Marker_Marker2CameraXfGet (c, CurrCamera, PoseXf, &IdentifyingCamera) );
243 MTC( Xform3D_RotQuaternionsGet(PoseXf, Quarternions) );
249 claronQuaternion[3] = Quarternions[0];
250 claronQuaternion[0] = Quarternions[1];
251 claronQuaternion[1] = Quarternions[2];
252 claronQuaternion[2] = Quarternions[3];
257 minusNinetyDegreeY[3] = sqrt(2.0)/2.0;
258 minusNinetyDegreeY[0] = 0;
259 minusNinetyDegreeY[1] = -1.0/(sqrt(2.0));
260 minusNinetyDegreeY[2] = 0;
265 returnValue.push_back(erg[3]);
266 returnValue.push_back(erg[0]);
267 returnValue.push_back(erg[1]);
268 returnValue.push_back(erg[2]);
277 char MarkerName[MT_MAX_STRING_LENGTH];
278 MTC( Marker_NameGet(c, MarkerName, MT_MAX_STRING_LENGTH, 0) );
279 std::string* returnValue =
new std::string(MarkerName);
280 return returnValue->c_str();
285 return this->isTracking;
bool IsMicronTrackerInstalled()
char calibrationDir[512]
Variable which holds the directory which should contain the file BumbleBee_6400420.calib. This directory is needed by the MTC library.
ClaronInterface()
standard constructor
std::vector< double > GetTipPosition(claronToolHandle c)
std::vector< double > GetTipQuaternions(claronToolHandle c)
~ClaronInterface()
standard destructor
const char * GetName(claronToolHandle c)
std::vector< double > GetPosition(claronToolHandle c)
bool StopTracking()
Clears all resources. After this method have been called the system isn't ready to track any longer...
bool StartTracking()
Opens the connection to the device and makes it ready to track tools.
void GrabFrame()
Grabs a frame from the camera.
std::vector< double > GetQuaternions(claronToolHandle c)
vnl_quaternion< ScalarType > Quaternion
bool isTracking
Variable is true if the device is tracking at the moment, false if not.
char markerDir[512]
Variable which holds a directory with some tool files in it. All this tools are trackable when the pa...
void Initialize(std::string calibrationDir, std::string toolFilesDir)
Initialization of claroninterface.
std::vector< claronToolHandle > GetAllActiveTools()