I am using Optitrack Camera SDK 1.2.2 with TrackIR v5 and Vector Clip Pro. I am
also using the sample code from VectorTracking, which I modified and included
into a user-defined class "TrackIR" (C++).
Code: Select all
// Initialize TrackIR-camera
bool TrackIR::StartTrackIR() {
// Initialize connected cameras
CameraManager::X().WaitForInitialization();
// Get a connected camera
camera = CameraManager::X().GetCamera();
// If no device connected, pop a message box and exit
if(camera==0) {
std::cout << "Please connect a camera, No Device Connected\n" << std::endl;
return 1;
}
// Set Video Mode
camera->SetVideoType(SegmentMode);
//camera->SetVideoType(PrecisionMode);
camera->SetExposure( EXPOSURE );
camera->SetThreshold( THRESHOLD );
camera->SetIntensity( INTENSITY );
// Start camera output
camera->Start();
// Turn on some overlay text so it's clear things are
// working even if there is nothing in the camera's view.
camera->SetTextOverlay(false);
// setup vectors for position-calculation
vec = cModuleVector::Create(); //new cModuleVector();
vecprocessor = new cModuleVectorProcessing();
camera->GetDistortionModel(lensDistortion);
// Plug distortion into vector module
cVectorSettings vectorSettings;
vectorSettings = *vec->Settings();
vectorSettings.Arrangement = cVectorSettings::TrackClipPro; // --> VectorClip or TrackClipPro
vectorSettings.Enabled = true;
cVectorProcessingSettings vectorProcessorSettings;
vectorProcessorSettings = *vecprocessor->Settings();
vectorProcessorSettings.Arrangement = cVectorSettings::TrackClipPro; // --> VectorClip or TrackClipPro
vectorProcessorSettings.ShowPivotPoint = false;
vectorProcessorSettings.ShowProcessed = false;
//// smoothing and speed
vectorProcessorSettings.SmoothingRotational = ROTSMOOTHING;
vectorProcessorSettings.ScaleRotationPitch = PITCHSCALE;
vectorProcessorSettings.ScaleRotationYaw = YAWSCALE;
vectorProcessorSettings.TrueView = true;
vecprocessor->SetSettings(vectorProcessorSettings);
// Plug in focal length in (mm) by converting it from pixels -> mm
vectorSettings.ImagerFocalLength = (lensDistortion.HorizontalFocalLength/((float) camera->PhysicalPixelWidth()))*camera->ImagerWidth();
vectorSettings.ImagerHeight = camera->ImagerHeight();
vectorSettings.ImagerWidth = camera->ImagerWidth();
vectorSettings.PrincipalX = camera->PhysicalPixelWidth()/2;
vectorSettings.PrincipalY = camera->PhysicalPixelHeight()/2;
vectorSettings.PixelWidth = camera->PhysicalPixelWidth();
vectorSettings.PixelHeight = camera->PhysicalPixelHeight();
vec->SetSettings(vectorSettings);
return 0;
}
// update positions
bool TrackIR::Update() {
// Fetch a new frame from the camera
Frame *frame = camera->GetFrame();
if(frame) {
// select first frame
vec->BeginFrame();
for( int i=0; i<frame->ObjectCount(); i++ ) {
cObject *obj = frame->Object(i);
float x = obj->X();
float y = obj->Y();
Core::Undistort2DPoint(lensDistortion,x,y);
vec->PushMarkerData(x, y, obj->Area(), obj->Width(), obj->Height());
}
vec->Calculate();
vecprocessor->PushData(vec);
// update results
//vecprocessor->GetPosition(x, y, z);
vecprocessor->GetOrientation(yaw, pitch, roll); // raw values
smoother->update( TrackIR::getCurvePitch(), TrackIR::getCurveYaw() ); // smoothed curve values
//vecprocessor->Smooth(1.0, 1.0, 1.0, 40.0, x, y, z, yaw, pitch, roll);
// frame release
frame->Release();
}
return 0;
}
My problem is, that I get coupling effects with yaw and pitch angles. If I look "just" to the right
or left (yaw) I also get an up and down movement (pitch)??! Are there any possibilities to
get rid of these coupling effects....or did I just made something wrong??
If I am using the TrackIR v5 software, everything works fine without coupling!
Best Regards
Michael