37 #include "DTrackSDK.hpp" 42 #include "SampleMath.h" 65 static void output_to_console();
66 static bool data_error_to_console();
72 int main(
int argc,
char** argv )
76 std::cout <<
"Usage: example_fingertracking <data port>" << std::endl;
80 std::istringstream portstream( argv[ 1 ] );
84 if ( portstream.fail() )
86 std::cout <<
"invalid port '" << argv[ 1 ] <<
"'" << std::endl;
96 std::cout <<
"DTrackSDK init error" << std::endl;
99 std::cout <<
"listening at local data port " << dt->
getDataPort() << std::endl;
107 while ( count++ < 1000 )
115 data_error_to_console();
127 static void output_to_console()
129 std::cout.precision( 3 );
130 std::cout.setf( std::ios::fixed, std::ios::floatfield );
142 std::cout <<
"DTrackSDK fatal error: invalid FINGERTRACKING id " << i << std::endl;
148 std::cout <<
"hand " << hand->
id <<
" not tracked" << std::endl;
152 std::cout <<
"hand " << hand->
id <<
" qu " << hand->
quality 153 <<
" lr " << ( ( hand->
lr == 0 ) ?
"left" :
"right") <<
" nf " << hand->
nfinger 158 for (
int j = 0; j < hand->
nfinger; j++ )
161 calculateSampleFinger( hand, j, sampleFinger );
163 std::cout <<
" finger " << j <<
" tip " << sampleFinger.locTip << std::endl;
164 std::cout <<
" outer " << sampleFinger.locOuter <<
" " << sampleFinger.rotOuter << std::endl;
165 std::cout <<
" middle " << sampleFinger.locMiddle <<
" " << sampleFinger.rotMiddle << std::endl;
166 std::cout <<
" root " << sampleFinger.locRoot <<
" " << sampleFinger.rotRoot << std::endl;
169 std::cout << std::endl;
188 sampleFinger.locOuter = sampleFinger.rotOuter * phalanxOuter + sampleFinger.locTip;
193 sampleFinger.rotMiddle = sampleFinger.rotOuter * jointOuter;
196 sampleFinger.locMiddle = sampleFinger.rotMiddle * phalanxMiddle + sampleFinger.locOuter;
201 sampleFinger.rotRoot = sampleFinger.rotMiddle * jointInner;
204 sampleFinger.locRoot = sampleFinger.rotRoot * phalanxInner + sampleFinger.locMiddle;
213 static bool data_error_to_console()
217 std::cout <<
"--- timeout while waiting for tracking data" << std::endl;
223 std::cout <<
"--- error while receiving tracking data" << std::endl;
229 std::cout <<
"--- error while parsing tracking data" << std::endl;
double getTimeStamp() const
Get timestamp since midnight.
bool receive()
Receive and process one tracking data packet.
unsigned short getDataPort() const
Get UDP data port where tracking data is received.
int lr
Left (0) or right (1) hand.
int getNumHand() const
Get number of calibrated A.R.T. FINGERTRACKING hands (as far as known).
Minimum class for a rotation.
A.R.T. FINGERTRACKING hand data (6DOF + fingers).
int nfinger
Number of fingers (maximum 5)
double rot[9]
Rotation matrix of outermost phalanx (column-wise)
double loc[3]
Location of tip (in [mm])
Minimum class for a position.
DTrack SDK main class derived from DTrackParser.
double anglephalanx[2]
Angle between phalanxes (order: outermost, innermost; in [deg])
double lengthphalanx[3]
Length of phalanxes (order: outermost, middle, innermost; in [mm])
unsigned int getFrameCounter() const
Get frame counter.
double quality
Quality (0.0 <= qu <= 1.0, no tracking if -1.0)
double loc[3]
Location of back of the hand (in [mm])
const DTrackHand * getHand(int id) const
Get A.R.T. FINGERTRACKING hand data.
int id
ID number (starting with 0)
Error while parsing command.
bool isDataInterfaceValid() const
Returns if UDP socket is open to receive tracking data on local machine.
Errors getLastDataError() const
Get last error at receiving tracking data (data transmission).
double rot[9]
Rotation matrix of back of the hand (column-wise)
struct DTrackSDK_Datatypes::DTrackHand::DTrackFinger finger[DTRACKSDK_HAND_MAX_FINGER]
Finger data (order: thumb, index finger, middle finger, ...)
bool isTracked() const
Returns if hand is currently tracked.