## TT_TrackableMarker Question

NaturalPoint - Mike
Posts: 1896
Joined: Tue Feb 01, 2011 8:41 am
Location: Corvallis, OR

### Re: TT_TrackableMarker Question

TT_MarkerPosition returns the local position of the marker relative to the centroid of the rigid body. If you need the position of an untracked marker, you can use the rigid body centroid position and orientation to transform the value given by TT_MarkerPosition and get the location where the marker would be.

nuLIMS
Posts: 4
Joined: Mon Jul 16, 2012 2:16 pm

### TT_TrackableMarker Question

I am trying to determine the position of a marker in a rigid body that may or may not be in the camera frame at a certain point of time. I notice that the function TT_TrackableMarker returns constant [x,y,z] for that marker even if the rigid body is moving. Does TT_TrackableMarker return the marker's relative position with respect to the trackable's frame? And if so, what would be the best way of determining where this marker is located in the global space? I can't do a distance from the trackable's location comparison due to the high likelihood of the markers I'm interested in being occluded. Thank you for your help.

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

It would be great to get some example code to do this transform.

I'm not sure how to apply the orientation returned by TT_TrackableLocation to the values returned by TT_TrackableMarker.

Cheers

Ideally if you could use XMVECTOR / XMMATRIX but I'm not too fussed.

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

I tried some code like this:
[font:Courier New][size:3pt]float p1[3],p2[3],p3[3],position[3],orientation[4],dummy;
TT_TrackableMarker(0,0,&(p1[0]),&(p1[1]),&(p1[2]));
TT_TrackableMarker(0,0,&(p2[0]),&(p2[1]),&(p2[2]));
TT_TrackableMarker(0,0,&(p3[0]),&(p3[1]),&(p3[2]));
TT_TrackableLocation(0,&(position[0], &(position[1], &(position[2]),&(orientation[0]), &(orientation[1]),&(orientation[2]),&(orientation[3]), &dummy,&dummy,&dummy);

XMMATRIX matrix = XMMatrixRotationQuaternion(XMVectorSet(orientation[0],orientation[1],orientation[2],orientation[3]));
matrix = XMMatrixMultiply(matrix,XMMatrixTranslation(position[0],position[1],position[2]));

XMVECTOR result = XMVector3Transform(XMVectorSet(p1[0],p1[1],p1[2],1),matrix);
p1[0]=XMVectorGetX(result);
p1[1]=XMVectorGetY(result);
p1[2]=XMVectorGetZ(result);

result = XMVector3Transform(XMVectorSet(p2[0],p2[1],p2[2].z,1),matrix);
p2[0]=XMVectorGetX(result);
p2[1]=XMVectorGetY(result);
p2[2]=XMVectorGetZ(result);

result = XMVector3Transform(XMVectorSet(p3[0],p3[1],p3[2].z,1),matrix);
p3[0]=XMVectorGetX(result);
p3[1]=XMVectorGetY(result);
p3[2]=XMVectorGetZ(result);[/size][/font]
The three resulting points do not match the points I get if I just use TT_FrameMarkerX/Y/Z etc...

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

Ah nevermind, just found the function
TT_TrackablePointCloudMarker

which does what I need. Shame it doesnt give you predicted position of any untracked points.

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

Sorry looks like it does untracked points too, just need to add more points to help the trackable

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

I added more points but TT_TrackablePointCloudMarker still returns empty vectors for untracked points so looks like I will need that working code like above

Thanks

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

Ok, gave up on quaternions and used the Euler angles. Looks like the following code does what I want.

Code: Select all

void PointCloudMarker(int RigidIndex, int MarkerIndex, float &x, float &y, float &z)
{
bool tracked;
TT_TrackablePointCloudMarker(RigidIndex,MarkerIndex,tracked,x,y,z);
if (!tracked)
{
TT_TrackableMarker(RigidIndex,MarkerIndex,&x,&y,&z);

float position[3],dummy,yaw, pitch, roll;
TT_TrackableLocation(0,&(position[0]), &(position[1]), &(position[2]),&dummy,&dummy,&dummy,&dummy, &yaw, &pitch, &roll);
// The Eulers are applied in the following order: Y, Z, X
XMMATRIX matrix = XMMatrixRotationAxis(XMVectorSet(0,1,0,0),-yaw*float(M_PI/180));
matrix = XMMatrixMultiply(matrix,XMMatrixRotationAxis(XMVectorSet(0,0,1,0),-pitch*float(M_PI/180)));
matrix = XMMatrixMultiply(matrix,XMMatrixRotationAxis(XMVectorSet(1,0,0,0),-roll*float(M_PI/180)));
matrix = XMMatrixMultiply(matrix,XMMatrixTranslation(position[0],position[1],position[2]));
XMVECTOR result = XMVector3Transform(XMVectorSet(x,y,z,1),matrix);
x=XMVectorGetX(result);
y=XMVectorGetY(result);
z=XMVectorGetZ(result);
}
}

bencrossman
Posts: 36
Joined: Wed Jun 06, 2012 10:02 pm

### Re: TT_TrackableMarker Question

That should be :

Code: Select all

TT_TrackableLocation(RigidIndex,
not:

Code: Select all

TT_TrackableLocation(0,