6dof with camera sdk

Post Reply
maister
Posts: 20
Joined: Fri Dec 18, 2009 10:12 am

6dof with camera sdk

Post by maister »

hello friends!!
I'm using Camera SDK to calculate 6 DOF of vector clip object.
I put this code:
------------------------------------------------
Frame *frame0 = camera0->GetFrame();

if(frame0)
{
//== Ok, we've received a new frame, lets do something
//== with it.
// frame0->Rasterize(framebuffer);

//printf("\n\n BeginFrame \n");
vec->BeginFrame();

for(int i=0; iObjectCount(); i++)
{
cObject *obj = frame0->Object(i);
obj->
float x = obj->X();
float y = obj->Y();
printf("\n\n x %.3f , y %.3f, z %.3f ", x,y);
Core::Predistort2DPoint(lensDistortion,x,y);

vec->PushMarkerData(x, y, obj->Area(), obj->Width(), obj->Height());
}
//printf("\n\n Calculate \n");
vec->Calculate();
//printf("\n\n PushData \n");
vecprocessor->PushData(vec);

//printf("\n\n GetPosition \n");
vecprocessor->GetPosition(xp,yp,zp);
//printf("\n\n GetOrientation \n");
vecprocessor->GetOrientation(yaw,pitch,roll);

printf("\n\n x %.3f , y %.3f , z %.3f ", xp,yp,zp);
printf("\n\n pitch %.3f , yaw %.3f , roll %.3f ", pitch,yaw,roll);
-----------------------------------------------------------
But this doesn't work, values of xp, yp and zp are 1.#QO and pitch yaw and roll have the same values.
What's wrong?
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: 6dof with camera sdk

Post by beckdo »

Hey Maister,

Sorry for the slow response. Did you happen to look at the vector tracking sample?
maister
Posts: 20
Joined: Fri Dec 18, 2009 10:12 am

Re: 6dof with camera sdk

Post by maister »

yes, This works!

thanks!
bclay
Posts: 2
Joined: Thu Jan 20, 2011 2:38 pm

Re: 6dof with camera sdk

Post by bclay »

I used the vector tracking sample as my base but it seems to be tailored to drawing the polygon represented by the detected points. I am looking for the X, Y, Z and heading Pitch and roll.

I modified the sample to call GetPosition and GetOrientation. I see rapid changes in the X value and smaller changes in the Y and Z but they do not seem to correspond to the movements that I am making.

the orientation does not change very often and never seems to be in response to the changes I amke to the clip.

The code I am using follows

int OptiTrackWrapper::UpdateTrack()
{
int status = -1;

if (mTrackingCamera != NULL)
{
Frame *frame = mTrackingCamera->GetFrame();

if (frame != NULL)
{
mTrackingVector->BeginFrame();

for (int index = 0; index ObjectCount(); index++)
{
cObject *object = frame->Object(index);

float x = object->X();
float y = object->Y();

Core::Predistort2DPoint(mLensDistortion,x,y);

mTrackingVector->PushMarkerData(x, y, object->Area(),
object->Width(), object->Height());
}

mTrackingVector->Calculate();
mTrackingVectorProcessor->PushData(mTrackingVector);

int numMarkers = mTrackingVectorProcessor->MarkerCount();

if (numMarkers > 0)
{
mTrackingVectorProcessor->GetOrientation(mTrackYaw, mTrackPitch, mTrackRoll);

mTrackingVectorProcessor->GetPosition(mTrackPosX, mTrackPosY, mTrackPosZ);

}

frame->Release();
}
}

return(status);
}
bclay
Posts: 2
Joined: Thu Jan 20, 2011 2:38 pm

Re: 6dof with camera sdk

Post by bclay »

I made some progress on this problem.

It appears that the routine in support.cpp to pump windows messages was not updating all of the fields on my MFC application. Orientation appears to be working correctly. GetPosition however does not return valid data. the values are always greater than 5.0+E68. The values returned by GetData are much better. They update in a logical manner although the Z value is around 400 when the clip is a couple of inches from the camera and around 850 when the clip is 2 feet from the camera.
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: 6dof with camera sdk

Post by beckdo »

Position information is reported in millimeters.

I would suggest you revisit the sample application as opposed to the MFC application you are working on. I called GetPosition & GetOrientation within the sample app and didn't see any undefined or out of the ordinary results--everything appeared to work as intended.

The sample application was intended to give an example of how to not only submit and receive raw vector solutions from the vector solver, but then utilize the vector processor to interpret and unburden the user from some unpleasant math in the case they wanted to do things like rotational or positional scaling.
Post Reply