Hi all,
currently I'm involved in developing a MITK plug-in that uses MicronTracker
3 to track movements of certain tools. So far I created a small GUI to set
up the tracking system step by step, so you can select the tracking device,
add tools and connect to the tracking system. However when I try to connect
after having added at least one tool, mbilog console shows error messages
like "Loaded 0 marker templates" and "MTC error: Grab frame time out". Below
I posted a little bit of code, so you can get an idea of what I've done. It
there any error in it? Or am I missing some facts?
(Explanation of how I want my GUI to work: First you select your tracking
device from a list (QComboBox) (calls method "SelectTrackingSystem(QString
name)), second you add tools by typing a name in a textfield, selecting a
tool calibration file from a QFileDialog and clicking on a button "Add
tool". This will call method AddTool(). When you added enough tools, method
ConnectTrackingSystem() will be called (again by clicking on a button). Now
this is the very point where the log messages appear)
//
// Tracking System related methods
//
void QmitkMITKUltraSoundCalibrationPluginView::GetCalibrationFile()
{
m_Controls->edCalibFile->setEnabled(true);
QString fileName = QFileDialog::getOpenFileName(m_Parent, "Select a
calibration file","C:\\Programme\\Claron
Technology\\MicronTracker\\Markers","All files(*.*)");
m_Controls->edCalibFile->setText(fileName);
m_Controls->edCalibFile->setEnabled(false);
}
void QmitkMITKUltraSoundCalibrationPluginView::SelectTrackingSystem(QString
name)
{
// if m_Source has already been instantiated, close open connections
if(m_Source.IsNotNull()){
if(m_Source->IsConnected()){
m_Source->Disconnect();
}
}
// clean up resources of m_Source and tracker
m_Source = NULL;
tracker = NULL;
switch(m_arTrackingSystems.indexOf(name)){
case 1:
{
// tracker must be set up completly (including tools) before
adding it to m_Source.
// Therefore m_Source will only be instantiated by calling
ConnectTrackingSystem()
// next time.
tracker = mitk::ClaronTrackingDevice::New();
break;
}
case 2:
{
// include your tracking system here
break;
}
default:
break;
}
}
void QmitkMITKUltraSoundCalibrationPluginView::AddTrackingTool()
{
if (tracker.IsNull())
tracker = mitk::ClaronTrackingDevice::New();
QString toolName = m_Controls->edToolName->text();
QString toolCalibFile = m_Controls->edCalibFile->text();
mitk::TrackingTool* t = tracker->AddTool(toolName.toLatin1(),
toolCalibFile.toLatin1());
if (t == NULL)
{
m_Controls->lblConnectionState->setText("Could not add tool
"+toolName);
}
else
{
m_Controls->lblConnectionState->setText("Tool '"+toolName+"'
added.");
}
}
void QmitkMITKUltraSoundCalibrationPluginView::ConnectTrackingSystem()
{
if (m_Source.IsNull())
{
m_Source = mitk::TrackingDeviceSource::New();
if(tracker.IsNotNull())
m_Source->SetTrackingDevice(tracker);
else {
m_Controls->lblConnectionState->setText("ERROR! Tracker not
initialized.");
m_Source = NULL;
return;
}
m_Source->Connect();
if (m_Source->IsConnected())
{
if (m_Source->GetTrackingDevice()->GetState() ==
mitk::TrackingDevice::Ready)
m_Controls->lblConnectionState->setText("MicronTracker is
connected and ready.");
else if (m_Source->GetTrackingDevice()->GetState() ==
mitk::TrackingDevice::Tracking)
m_Controls->lblConnectionState->setText("MicronTracker is
connected and tracking.");
else if (m_Source->GetTrackingDevice()->GetState() ==
mitk::TrackingDevice::Setup)
m_Controls->lblConnectionState->setText("MicronTracker is
connected but not ready.");
else
m_Controls->lblConnectionState->setText("MicronTracker is
connected (unknown state).");
}
else{
m_Controls->lblConnectionState->setText("MicronTracker is not
connected.");
}
}
else{
m_Controls->lblConnectionState->setText("ERROR! TrackingDeviceSource
is stil alive!");
}
}
void QmitkMITKUltraSoundCalibrationPluginView::DisconnectTrackingSystem()
{
if(m_Source.IsNotNull()){
m_Source->Disconnect();
if (m_Source->IsConnected())
{
m_Controls->lblConnectionState->setText("ERROR! MicronTracker is
still connected.");
return;
}
else{
m_Controls->lblConnectionState->setText("MicronTracker is not
connected.");
m_Source = NULL;
tracker = NULL;
}
} else {
m_Controls->lblConnectionState->setText("ERROR! TrackingDeviceSource
is not alive!");
}
}
--
Michael Kirches
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users