I'm having troubles using the GetFrame(Long*,INPCameraFrame**) function.
I've checked the previous posts about this problem but haven't found a clear answer. I also went through the "OptiTrack API, Version: 1.81 For SDK Version 1.1.034 Date: 02/21/2008" but I haven't found anything.
Here is a description of my problem:
Device: TrackIR pro 73010
Software: Windows XP SP2, OptiTrack SDK version 1.1.034
Hereafter is a simplified version of the failing code (base on the code found here http://forum.naturalpoint.com/forum/ubb ... mber=17794 ). I'm compiling with VC++ 2005 Express. The GetFrame function sets the pFrame pointer to NULL, while from what I'm understood it shouldn't... and I've also set the option to *not* send empty frames. So the following line
Code: Select all
hr=pFrame->get_Count(&vCount);
All samples downloaded from the OptiTrack SDK download page also failed to run(same error). However this code (and examples) works fine with SDK 1.1.031 or 1.1.030.
I'd rather not use
Code: Select all
if(pFrame==NULL){continue;}
Many Thanks.
======================CODE================================
#include "stdafx.h"
#include
#include
#include "optitrack.h"
INPCameraCollection *pCameraCollection=NULL;
INPCamera *pCamera=NULL;
INPCameraFrame *pFrame=NULL;
#define HRCHECK(message) if (hr!=S_OK) { fprintf(stderr, "%s\n", message); return 0; }
int main(int argc, char* argv[])
{
HRESULT hr;
LONG count;
LONG vCount;
VARIANT voption;
int running = 1;
CoInitialize(NULL);
// create CameraCollection and Vector objects:
hr = CoCreateInstance(__uuidof(NPCameraCollection), NULL, CLSCTX_ALL,
__uuidof(INPCameraCollection), (void **) &pCameraCollection);
HRCHECK("CoCreateInstance for CameraCollection");
// find all the cameras:
hr = pCameraCollection->Enum();
HRCHECK("CameraCollection->Enum");
hr = pCameraCollection->get_Count(&count);
HRCHECK("CameraCollection->get_Count");
if (count Item(0, &pCamera);
HRCHECK("CameraCollection->Item");
hr = pCamera->Open();
HRCHECK("Camera->Open");
// turn on illumination LEDs
hr = pCamera->SetLED(NP_LED_ONE, VARIANT_TRUE);
HRCHECK("Camera->SetLED");
voption.vt = VT_BOOL;
voption.boolVal = VARIANT_FALSE;
hr = pCamera->SetOption(NP_OPTION_SEND_EMPTY_FRAMES, voption);
HRCHECK("Camera->SetOption");
hr = pCamera->Start();
HRCHECK("Camera->Start");
while(running) {
hr = pCamera->GetFrame(INFINITE, &pFrame);
HRCHECK("pCamera->GetFrame");
//if(pFrame==NULL){
// continue;
//}
hr=pFrame->get_Count(&vCount);
HRCHECK("pFrame->get_Count");
printf("objects count: %d\n",vCount);
hr = pFrame->Free();
//pFrame=NULL;
}
// shutdown
pCamera->SetLED(NP_LED_ONE, VARIANT_FALSE);
pCamera->Stop();
pCamera->Close();
CoUninitialize();
return 0;
}