Modified win32 sample hangs

niallm
Posts: 23
Joined: Tue Feb 22, 2005 5:00 am
Location: London Ontario Canada

Modified win32 sample hangs

Post by niallm »

Hi,

I've modified the win32 sample to report the vector clip data. After aprox. 10000 frames it hangs on the getframe().
If at 9000 frames I stop then start the camera it continues on. Any ideas as to what's going on?
I'm using NPVECTOR3 to get the vector data and also set the dist01,dist02,dist12 as well as the focal length of the lens.
I originally tried a timeout of 20 milleseconds in the call but it seemed to hang quicker, and If I opened the task manager it crashed but no exit and unkillable. Have to unplug camera for it to shutdown.
So I but a 1 millisecond sleep prior to getframe which allowed it to run to 10000 frames.

Hope you can Help!
Any Ideas on when your point cloud / rigid body software will be ready? Soon I hope.

Niall
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Modified win32 sample hangs

Post by beckdo »

Hi Niall,

The win32 sample does not exhibit this behavior on my development machine which explains why I missed this issue. I have however been able to reproduce it and will find a solution and get back to you.

The Point Cloud library release is coming up very soon, likely in the next couple weeks.

Thanks,
Doug
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Modified win32 sample hangs

Post by beckdo »

Hi Niall,

I've submitted a fix for this issue. Contact support for a beta build of the SDK. There will be a new release of the OptiTrack SDK in the next couple weeks that will include this fix as well.
niallm
Posts: 23
Joined: Tue Feb 22, 2005 5:00 am
Location: London Ontario Canada

Re: Modified win32 sample hangs

Post by niallm »

Thanks Doug.

Looking forward to the release of the new software.

Niall
dlecoutre
Posts: 6
Joined: Wed Apr 18, 2007 3:23 pm

Re: Modified win32 sample hangs

Post by dlecoutre »

Hi,

Sorry for my English, I'm foreigner.
I've got the same bug, I'm programming in JNI to use the camera with java. I used the Win32 sample for my application, but between 10000-9000 frame it crash at GetData(). When is the new release of the OptiTrackSDK ?

Thanks,
VincentG
Posts: 7728
Joined: Mon Jul 17, 2006 5:00 am
Location: Corvallis, Oregon

Re: Modified win32 sample hangs

Post by VincentG »

The release of the new SDK, is several weeks out, at least.....
dlecoutre
Posts: 6
Joined: Wed Apr 18, 2007 3:23 pm

Re: Modified win32 sample hangs

Post by dlecoutre »

First I apologize for my writing english because I am not english.
I've modified the loop because I need to use the camera for an undefined time. The programm freeze each time between 9000-10000 loop ( generally at 10000).
I had install the last SDK version. That is why I was asking if you will have a new release soon.

Thanks,

Code: Select all

//========================================================================-----
//== OptiTrack WIN32 Sample Application
//== Copyright 20067 NaturalPoint
//== 
//== This sample is intended to show how to properly access and control
//== OptiTrack cameras.  The application does the following:
//==
//== 1. Initializes the OptiTrack COM Component.
//== 2. Displays information about all connected cameras.
//== 3. Starts the first camera in the system and displays ongoing info.
//== 4. Unintializes the OptiTrack cameras, COM, and terminates.

//== INCLUDES ============================================================-----

#include "stdafx.h"
#include <conio.h>    //== For sample simplicity: kbhit()

//== NECESSARY OPTITRACK INCLUDES AND DEFINITIONS ========================-----

#include <objbase.h>
#include <atlbase.h>
#include "optitrack.h"
#import  "optitrack.tlb"
#include <iostream.h>
INPCameraCollection *pCameraCollection;
INPCamera *pCamera;
INPCameraFrame *pFrame;
INPVector *pVector;
double ncompteur;
#define HRCHECK(message) if (FAILED(hr)) { fprintf(stderr, "%s\n", message); return 0; }
//== SAMPLE APPLICATION ENTRY POINT ======================================-----

int main(int argc, char* argv[])
{
	HRESULT hr;
	LONG count;
	LONG misc;
	LONG waittime;
	ncompteur=1;
	VARIANT vx, vy, vz;
	VARIANT vyaw, vpitch, vroll;
	VARIANT voption;

	int running = 1;
	int toerrors = 0;

	printf("Hello World!\n");

	// probably not needed, but doesn't hurt:
	VariantInit(&vx);
	VariantInit(&vy);
	VariantInit(&vz);
	VariantInit(&vyaw);
	VariantInit(&vpitch);
	VariantInit(&vroll);
	VariantInit(&voption);

	CoInitialize(NULL);  // Startup Microsoft crap

	// create CameraCollection and Vector objects:

	hr = CoCreateInstance(__uuidof(NPCameraCollection), NULL, CLSCTX_ALL,
	__uuidof(INPCameraCollection), (void **) &pCameraCollection);
	HRCHECK("CoCreateInstance for CameraCollection");

	hr = CoCreateInstance(__uuidof(NPVector), NULL, CLSCTX_ALL,
	__uuidof(INPVector), (void **) &pVector);
	HRCHECK("CoCreateInstance for Vector");

	// find all the cameras:
	hr = pCameraCollection->Enum();
	HRCHECK("CameraCollection->Enum");

	hr = pCameraCollection->get_Count(&count);
	HRCHECK("CameraCollection->get_Count");

	if (count < 1) {
		fprintf(stderr, "camera count < 1\n");
		return 0;
	}

	// get one:
	hr = pCameraCollection->Item(0, &pCamera);
	HRCHECK("CameraCollection->Item");

	hr = pCamera->get_SerialNumber(&misc);
	HRCHECK("Camera->get_SerialNumber");

	printf("serial number = %ld\n", misc);

	hr = pCamera->Open();
	HRCHECK("Camera->Open");

	// turn on illumination LEDs
	hr = pCamera->SetLED(NP_LED_ONE, VARIANT_TRUE);
	HRCHECK("Camera->SetLED");

	#if 0
		voption.vt = VT_BOOL;
		voption.boolVal = VARIANT_TRUE;
		hr = pCamera->SetOption(NP_OPTION_SEND_EMPTY_FRAMES, voption);
		HRCHECK("Camera->SetOption");
	#endif

	hr = pCamera->Start();
	HRCHECK("Camera->Start");

	waittime = 20; // value in milliseconds; 0 = don't wait; INFINITE = wait till data
	//waittime = INFINITE;

	pVector->Reset();
	HRCHECK("Vector->Reset");

	running = 10000; // run ~1 minute for waittime=10 ms

//  while(running--) {
	while(1) {
		hr = pCamera->GetFrame(waittime, &pFrame);
		

		if (FAILED(hr)) {
		  // fprintf(stderr,"Camera->GetFrame %x ", hr);

		//printf ("hr is %d\n", hr);
		  switch(hr) {
			case S_OK:
				fprintf(stderr, "OK\n"); 
				break;

			case E_POINTER:
				fprintf(stderr, "E_POINTER\n"); 
				break;

			case NP_E_DEVICE_DISCONNECTED:
				fprintf(stderr, "NP_E_DEVICE_DISCONNECTED\n"); 
				break;

			case NP_E_DEVICE_NOT_SUPPORTED:
				fprintf(stderr, "NP_E_DEVICE_NOT_SUPPORTED\n"); 
				break;

			case HRESULT_FROM_WIN32(ERROR_TIMEOUT):
				fprintf(stderr, "HRESULT_FROM_WIN32(ERROR_TIMEOUT)\n");
				toerrors++;
				break;
			
			default:
				fprintf(stderr, "default\n"); 
				break;
		  } //switch
	
	//	else {
		  //fprintf(stderr, "FAILED(hr) returned false!!!\n");
		//}
		  continue;
	} //if

    hr = pVector->Update(pCamera, pFrame);
    HRCHECK("Vector->Update");

    hr = pVector->get_X(&vx);
    HRCHECK("Vector->get_X");

    hr = pVector->get_Y(&vy);
    HRCHECK("Vector->get_Y");

    hr = pVector->get_Z(&vz);
    HRCHECK("Vector->get_Z");

    hr = pVector->get_Yaw(&vyaw);
    HRCHECK("Vector->get_Yaw");

    hr = pVector->get_Pitch(&vpitch);
    HRCHECK("Vector->get_Pitch");

    hr = pVector->get_Roll(&vroll);
    HRCHECK("Vector->get_Roll");

	printf(" x=%.3f  y=%.3f  z=%.3f   yaw=%.3f  pitch=%.3f  roll=%.3f c=%.1f  \r",
	vx.dblVal, vy.dblVal, vz.dblVal, vyaw.dblVal, vpitch.dblVal, vroll.dblVal,ncompteur);
	ncompteur=ncompteur+1;
	hr = pFrame->Free();

  }

  printf("\n\n%d timeouts\n", toerrors);

  printf("\nFin\n");

  // shut everything down
  pCamera->SetLED(NP_LED_ONE, VARIANT_FALSE);
  pCamera->Stop();
  pCamera->Close();

  CoUninitialize();

  return 0;
}  
VincentG
Posts: 7728
Joined: Mon Jul 17, 2006 5:00 am
Location: Corvallis, Oregon

Re: Modified win32 sample hangs

Post by VincentG »

Is it still having issues, after the SDK that I sent you yesterday?
dlecoutre
Posts: 6
Joined: Wed Apr 18, 2007 3:23 pm

Re: Modified win32 sample hangs

Post by dlecoutre »

Yes but in a different way. When I execute the programm VC6Console.exe crash before the first loop (It is a VC6 project).
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Modified win32 sample hangs

Post by beckdo »

You'll want to rebuild your application after installing the beta SDK. That will solve your crash.
Post Reply