[IGSTK-Users] not able to display the tracker tool
steve.berger at istb.unibe.ch
steve.berger at istb.unibe.ch
Fri Mar 14 11:17:02 EDT 2014
Hi,
I am following the examples and tests to display a tracking tool in IGSTK, but I cannot display the tracking tool.
I am able to track the position of the tool, print it, but not able to display it in the 3DView.
My code is very simple, it has just a main.cpp (see below) as well as a QT pro file (below).
I already tried a very lot, but can't find the error...
So where is the error ???
I use a Polaris camera, IGSTK 5.2 along with QT.
Kind regards,
Steve Berger
--------------------------------------------------------------------------
MAIN.CPP
-------------------------------------------------------------------------
#include <QApplication>
#include <QtTest/QTest>
#include <QMainWindow>
#include <iostream>
#include "igstkView2D.h"
#include "igstkView3D.h"
#include "igstkAxesObject.h"
#include "igstkAxesObjectRepresentation.h"
#include "igstkBoxObject.h"
#include "igstkBoxObjectRepresentation.h"
#include "igstkMeshObject.h"
#include "igstkMeshObjectRepresentation.h"
#include "igstkEvents.h"
#include "igstkTransformObserver.h"
#include "igstkEllipsoidObject.h"
#include "igstkCylinderObject.h"
#include "igstkEllipsoidObjectRepresentation.h"
#include "igstkCylinderObjectRepresentation.h"
#include "igstkLogger.h"
#include "itkStdStreamLogOutput.h"
#include "igstkPolarisTracker.h"
#include "igstkPolarisTrackerTool.h"
#include "igstkSerialCommunication.h"
#include "igstkQTWidget.h"
int main( int argc, char * argv[])
{
igstk::RealTimeClock::Initialize();
// *******************************
// INSTANCES
//********************************
// logger
igstk::Object::LoggerType::Pointer m_Logger = igstk::Object::LoggerType::New();
itk::StdStreamLogOutput::Pointer m_LogOutput = itk::StdStreamLogOutput::New();
// tracker
igstk::PolarisTracker::Pointer m_Tracker = igstk::PolarisTracker::New();
igstk::PolarisTrackerTool::Pointer m_TrackerTool = igstk::PolarisTrackerTool::New();
igstk::SerialCommunication::Pointer m_Communication = igstk::SerialCommunication::New();
//observer
igstk::TransformObserver::Pointer coordSystemAObserver = igstk::TransformObserver::New();
//transformation
const double longestValidityTime = igstk::TimeStamp::GetLongestPossibleTime();
igstk::Transform identityTransform;
identityTransform.SetToIdentity(longestValidityTime);
igstk::Transform boxTransform;
igstk::Transform::VectorType boxTranslation;
igstk::Transform::VersorType boxRotation;
igstk::Transform::ErrorType boxErrorValue = 0.01; // 10 microns
//objects
igstk::EllipsoidObject::Pointer ellipsoid = igstk::EllipsoidObject::New();
igstk::EllipsoidObjectRepresentation::Pointer ellipsoidRepresentation = igstk::EllipsoidObjectRepresentation::New();
igstk::CylinderObject::Pointer cylinder = igstk::CylinderObject::New();
igstk::CylinderObjectRepresentation::Pointer cylinderRepresentation = igstk::CylinderObjectRepresentation::New();
igstk::BoxObject::Pointer box = igstk::BoxObject::New();
igstk::BoxObjectRepresentation::Pointer boxRepresentation = igstk::BoxObjectRepresentation::New();
//views
igstk::View3D::Pointer View3D = igstk::View3D::New();
//QT
QApplication myApp(argc, argv);
QMainWindow myMainWindow;
igstk::QTWidget* qtWidget3D = new igstk::QTWidget();
// *******************************
// LOGGER
//********************************
m_LogOutput->SetStream(std::cout);
m_Logger->AddLogOutput(m_LogOutput);
//m_Logger->SetPriorityLevel( itk::Logger::DEBUG);
// *******************************
// OBJECTS
//********************************
// Create the ellipsoid
ellipsoid->SetRadius(100,100,150);
ellipsoidRepresentation->RequestSetEllipsoidObject( ellipsoid );
ellipsoidRepresentation->SetColor(0.0,1.0,0.0);
ellipsoidRepresentation->SetOpacity(0.2);
// Create the cylinder
cylinder->SetRadius(20.0);
cylinder->SetHeight(300.0);
cylinderRepresentation->RequestSetCylinderObject( cylinder );
cylinderRepresentation->SetColor(1.0,0.0,0.0);
cylinderRepresentation->SetOpacity(1.0);
// Create the box
box->SetSize(80,80,80);
boxRepresentation->RequestSetBoxObject( box );
boxRepresentation->SetColor(0.0,0.0,1.0);
boxRepresentation->SetOpacity(1.0);
boxTranslation[0] = 100.0;
boxTranslation[1] = 200.0;
boxTranslation[2] = -1300.0;
boxRotation.Set( 0.0, 0.0, 0.0, 1.0 );
boxTransform.SetTranslationAndRotation(boxTranslation, boxRotation, boxErrorValue, longestValidityTime );
// *******************************
// TRACKER
//********************************
//serial communication
//m_Communication->SetLogger( m_Logger );
m_Communication->SetPortNumber( igstk::SerialCommunication::PortNumber0 );
m_Communication->SetParity( igstk::SerialCommunication::NoParity );
m_Communication->SetBaudRate( igstk::SerialCommunication::BaudRate115200 );
m_Communication->SetDataBits( igstk::SerialCommunication::DataBits8 );
m_Communication->SetStopBits( igstk::SerialCommunication::StopBits1 );
m_Communication->SetHardwareHandshake(igstk::SerialCommunication::HandshakeOff );
m_Communication->SetCapture( true );
igstk::Communication::ResultType openCommOutput = m_Communication->OpenCommunication();
if( openCommOutput == igstk::Communication::SUCCESS)
std::cout<<"SerialComm: OpenCommunication OK"<<std::endl;
else if(openCommOutput == igstk::Communication::TIMEOUT)
std::cout<<"SerialComm: OpenCommunication TIMEOUT"<<std::endl;
else if(openCommOutput == igstk::Communication::FAILURE)
std::cout<<"SerialComm: OpenCommunication FAILED"<<std::endl;
// tracker
//m_Tracker->SetLogger(m_Logger);
m_Tracker->SetCommunication(m_Communication);
m_Tracker->RequestOpen();
// tool
// m_TrackerTool->SetLogger(m_Logger);
m_TrackerTool->RequestSelectWirelessTrackerTool();
m_TrackerTool->RequestSetSROMFileName("../Resources/TrackerROMfiles/ISTB0050.rom");
m_TrackerTool->RequestConfigure();
m_TrackerTool->RequestAttachToTracker(m_Tracker);
//observer
coordSystemAObserver->ObserveTransformEventsFrom(m_TrackerTool);
//start tracking
m_Tracker->RequestStartTracking();
// *******************************
// TRANSFORM AND PARENTS
//********************************
View3D->RequestSetTransformAndParent(identityTransform, ellipsoid);
box->RequestSetTransformAndParent( boxTransform, ellipsoid );
m_Tracker->RequestSetTransformAndParent(identityTransform, View3D);
cylinder->RequestSetTransformAndParent(identityTransform, m_TrackerTool);
// *******************************
// 3DView
//********************************
//View3D->SetLogger(m_Logger);
View3D->RequestAddObject(ellipsoidRepresentation->Copy());
View3D->RequestAddObject(cylinderRepresentation);
View3D->RequestAddObject(boxRepresentation->Copy());
View3D->SetRefreshRate( 30 ); // Hz
View3D->RequestResetCamera();
View3D->RequestStart();
// *******************************
// QT
//********************************
qtWidget3D->RequestSetView( View3D );
qtWidget3D->RequestEnableInteractions();
myMainWindow.setCentralWidget(qtWidget3D);
myMainWindow.setFixedSize(720,576);
myMainWindow.show();
// *******************************
// MAIN LOOP
//********************************
while(1)
{
std::cout<<"\n\n"<<std::endl;
QTest::qWait(250);
igstk::PulseGenerator::CheckTimeouts();
//print tracker position
igstk::Transform trackerToolTransform;
::itk::Vector<double, 3> trackerToolTranslation;
coordSystemAObserver->Clear();
m_TrackerTool->RequestGetTransformToParent();
if (coordSystemAObserver->GotTransform())
{
trackerToolTransform = coordSystemAObserver->GetTransform();
if ( trackerToolTransform.IsValidNow() )
{
trackerToolTranslation = trackerToolTransform.GetTranslation();
std::cout << "Trackertool :"
<< m_TrackerTool->GetTrackerToolIdentifier()
<< "\t\t Position = ("
<< trackerToolTranslation[0]
<< ","
<< trackerToolTranslation[1]
<< ","
<< trackerToolTranslation[2]
<< ")" << std::endl;
}
}
}
return EXIT_SUCCESS;
}
--------------------------------------------------------------------------
.PRO FILE
-------------------------------------------------------------------------
QT += core gui network \
widgets printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += testlib #to be able to use the QtTest library
DESTDIR = $$PWD #to say that we are working from this project directory (to easily set up relative filepath)
HEADERS += \
SOURCES += \
src/main.cpp \
#include the geometry library
INCLUDEPATH += /usr/local/include/Geometry
#include IGSTK
INCLUDEPATH += /usr/local/include/IGSTK
INCLUDEPATH += /home/berger/SpineBot/kitware/igstk/IGSTK-5.2/bin/Testing/
#include ITK
INCLUDEPATH += /usr/local/include/ITK-4.4
INCLUDEPATH += /usr/local/include/ITK-4.4/vnl
#include VTK
INCLUDEPATH += /usr/local/include/vtk-5.10
#lib geometry
LIBS += /usr/local/lib/libGeometry.a
#lib igstk
LIBS += -L/usr/local/lib/IGSTK
LIBS += -lIGSTK
LIBS += -lSceneGraphVisualization
#lib ITK
LIBS += -L/usr/local/lib/
LIBS += -lITKBiasCorrection-4.4
LIBS += -lITKBioCell-4.4
LIBS += -lITKCommon-4.4
LIBS += -lITKDICOMParser-4.4
LIBS += -litkdouble-conversion-4.4
LIBS += -lITKEXPAT-4.4
LIBS += -lITKFEM-4.4
LIBS += -litkgdcmCommon-4.4
LIBS += -litkgdcmDICT-4.4
LIBS += -litkgdcmDSED-4.4
LIBS += -litkgdcmIOD-4.4
LIBS += -litkgdcmjpeg12-4.4
LIBS += -litkgdcmjpeg16-4.4
LIBS += -litkgdcmjpeg8-4.4
LIBS += -litkgdcmMSFF-4.4
LIBS += -litkgdcmuuid-4.4
LIBS += -lITKgiftiio-4.4
LIBS += -litkhdf5-4.4
LIBS += -litkhdf5_cpp-4.4
LIBS += -lITKIOBioRad-4.4
LIBS += -lITKIOBMP-4.4
LIBS += -lITKIOCSV-4.4
LIBS += -lITKIOGDCM-4.4
LIBS += -lITKIOGE-4.4
LIBS += -lITKIOGIPL-4.4
LIBS += -lITKIOHDF5-4.4
LIBS += -lITKIOImageBase-4.4
LIBS += -lITKIOIPL-4.4
LIBS += -lITKIOJPEG-4.4
LIBS += -lITKIOLSM-4.4
LIBS += -lITKIOMesh-4.4
LIBS += -lITKIOMeta-4.4
LIBS += -lITKIONIFTI-4.4
LIBS += -lITKIONRRD-4.4
LIBS += -lITKIOPNG-4.4
LIBS += -lITKIOSiemens-4.4
LIBS += -lITKIOSpatialObjects-4.4
LIBS += -lITKIOStimulate-4.4
LIBS += -lITKIOTIFF-4.4
LIBS += -lITKIOTransformBase-4.4
LIBS += -lITKIOTransformHDF5-4.4
LIBS += -lITKIOTransformInsightLegacy-4.4
LIBS += -lITKIOTransformMatlab-4.4
LIBS += -lITKIOVTK-4.4
LIBS += -lITKIOXML-4.4
LIBS += -litkjpeg-4.4
LIBS += -lITKKLMRegionGrowing-4.4
LIBS += -lITKLabelMap-4.4
LIBS += -lITKMesh-4.4
LIBS += -lITKMetaIO-4.4
LIBS += -litkNetlibSlatec-4.4
LIBS += -lITKniftiio-4.4
LIBS += -lITKNrrdIO-4.4
LIBS += -litkopenjpeg-4.4
LIBS += -lITKOptimizers-4.4
LIBS += -lITKOptimizersv4-4.4
LIBS += -lITKPath-4.4
LIBS += -litkpng-4.4
LIBS += -lITKPolynomials-4.4
LIBS += -lITKQuadEdgeMesh-4.4
LIBS += -lITKReview-4.4
LIBS += -lITKSpatialObjects-4.4
LIBS += -lITKStatistics-4.4
LIBS += -litksys-4.4
LIBS += -litktiff-4.4
LIBS += -litkv3p_lsqr-4.4
LIBS += -litkv3p_netlib-4.4
LIBS += -litkvcl-4.4
LIBS += -lITKVideoCore-4.4
LIBS += -lITKVideoIO-4.4
LIBS += -litkvnl-4.4
LIBS += -litkvnl_algo-4.4
LIBS += -lITKVNLInstantiation-4.4
LIBS += -lITKVTK-4.4
LIBS += -lITKWatersheds-4.4
LIBS += -litkzlib-4.4
LIBS += -lITKznz-4.4
#lib VTK
LIBS += -L/usr/local/lib/vtk-5.10
LIBS += -lLSDyna
LIBS += -lMapReduceMPI
LIBS += -lmpistubs
LIBS += -lQVTK
LIBS += -lvtkalglib
LIBS += -lvtkCharts
LIBS += -lvtkCommon
LIBS += -lvtkDICOMParser
LIBS += -lvtkexoIIc
LIBS += -lvtkexpat
LIBS += -lvtkFiltering
LIBS += -lvtkfreetype
LIBS += -lvtkftgl
LIBS += -lvtkGenericFiltering
LIBS += -lvtkGeovis
LIBS += -lvtkGraphics
LIBS += -lvtkhdf5
LIBS += -lvtkhdf5_hl
LIBS += -lvtkHybrid
LIBS += -lvtkImaging
LIBS += -lvtkInfovis
LIBS += -lvtkIO
LIBS += -lvtkjpeg
LIBS += -lvtklibxml2
LIBS += -lvtkmetaio
LIBS += -lvtkNetCDF
LIBS += -lvtkNetCDF_cxx
LIBS += -lvtkpng
LIBS += -lvtkproj4
LIBS += -lvtkQtChart
LIBS += -lvtkRendering
LIBS += -lvtksqlite
LIBS += -lvtksys
LIBS += -lvtktiff
LIBS += -lvtkverdict
LIBS += -lvtkViews
LIBS += -lvtkVolumeRendering
LIBS += -lvtkWidgets
LIBS += -lvtkzlib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20140314/4210df88/attachment-0001.html>
More information about the IGSTK-Users
mailing list