Simple INPVector application

Post Reply
Bhiefer
Posts: 3
Joined: Wed Mar 12, 2008 2:52 pm

Simple INPVector application

Post by Bhiefer »

Hi,
I'm trying to write a simple application with INPVector, but it fails with acces violation exception when I call Update method on the Vector. Please could you tell me what else is need to be set?

I tried to run code from this topic
http://forum.naturalpoint.com/forum/ubb ... mber=17794
and it fails on Update method too. But vector tracking in Optitrack SDK Sample Application works good.

Thanks for help, Mark


code:

CoInitialize(NULL);

CComPtr cameraCollection;
CComPtr camera;
CComPtr frame;
CComPtr vector;

cameraCollection.CoCreateInstance(CLSID_NPCameraCollection);
vector.CoCreateInstance(CLSID_NPVector);

cameraCollection->Enum();

long cameraCount = 0;

cameraCollection->get_Count(&cameraCount);

if(cameraCount==1)
{
cameraCollection->Item(0, &camera);

camera->Open();

camera->SetOption(NP_OPTION_VIDEO_TYPE,(CComVariant) 2 );
camera->SetOption(NP_OPTION_FRAME_DECIMATION,(CComVariant) 0 );
camera->SetOption(NP_OPTION_NUMERIC_DISPLAY_ON, (CComVariant)32);
camera->SetOption(NP_OPTION_FRAME_RATE,(CComVariant) 25);
camera->SetOption(NP_OPTION_THRESHOLD,(CComVariant) 150);
camera->SetOption(NP_OPTION_EXPOSURE,(CComVariant) 55);
camera->SetOption(NP_OPTION_INTENSITY,(CComVariant) 1);
camera->SetOption(NP_OPTION_MINIMUM_SEGMENT_LENGTH,(CComVariant) 75);
camera->SetOption(NP_OPTION_MAXIMUM_SEGMENT_LENGTH,(CComVariant) 200);
camera->Start();
camera->GetFrame(0, &frame);

vector->Reset();
vector->Update(camera,frame); // HERE IT FAILS

.
.
.

camera->Stop();
camera->Close();
camera.Release();
vector.Release();
}
cameraCollection.Release();
CoUninitialize();

ExitProcess(1);
Birch
Posts: 1139
Joined: Thu Jan 30, 2003 5:00 am
Location: Corvallis, Oregon

Re: Simple INPVector application

Post by Birch »

Are you checking to see whether the frame is not null before using it?

Code: Select all

if (frame != 0)
{
  // ok to use frame
}
Bhiefer
Posts: 3
Joined: Wed Mar 12, 2008 2:52 pm

Re: Simple INPVector application

Post by Bhiefer »

I tested it and frame==0. Then I checked the HRESULT of GetFrame method and it was S_OK. Well could you advice me, what else can be wrong? Thanks
Birch
Posts: 1139
Joined: Thu Jan 30, 2003 5:00 am
Location: Corvallis, Oregon

Re: Simple INPVector application

Post by Birch »

To make sure there is not a misunderstanding :

If the frame==0, then the frame should not be used. Even if the return code was S_OK for that GetFrame call.
Bhiefer
Posts: 3
Joined: Wed Mar 12, 2008 2:52 pm

Re: Simple INPVector application

Post by Bhiefer »

I understood. My question is, why frame is null? I initialize it and other camera's methods work(LED etc.).
Birch
Posts: 1139
Joined: Thu Jan 30, 2003 5:00 am
Location: Corvallis, Oregon

Re: Simple INPVector application

Post by Birch »

Sometimes the call is not able to to retrieve a valid frame, but it should retrieve valid frames the rest of the time. If it fails every time, then there may be another issue.
Post Reply