Tracking Tools sample code

Post Reply
dashesy
Posts: 33
Joined: Fri Mar 27, 2009 8:47 am
Location: Utah

Tracking Tools sample code

Post by dashesy »

I was wondering when we can get a working full example for the TT2.0 API.
In order to capture with 100fps we decided to use TT2.0 in our products (instead of OptiTrack). The TT2.0 software itself seems to work great, and the single camera tracking algorithm will make it just perfect.

The single camera mode (accessible in TT2.0 software in "Camera Investigation" option) is exactly what I want, with options such as "video type" and exposure settings. You can change these settings with "Right Click" in TT2.0 software.

I am interested to know how I can change some camera parameters such as video type and exposure settings using TT2.0 API. The include file "NPTrackingTools.h" does not specify how.

Ok here is the code that I have so far:

Code: Select all

int main()
{
    int windowWidth = 640;
    int windowHeight = 480;
	long cameraCount  = 0;
	unsigned int  frameCounter = 0;
	TT_Initialize();
	cameraCount = TT_CameraCount();
	if(cameraCount>0)
	{
        if (!ptc_open("TT Sample", windowWidth, windowHeight)) return 1;
		while(!TimeToClose)
		{
			MSG msg;
			if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
			{
				if(GetMessage( &msg, NULL, 0, 0 ) )
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
			TT_CameraFrameBuffer(0, windowWidth, windowHeight, 0, 1, frameBuffer);
			// display the frame data
			ptc_update(frameBuffer);
			Sleep(10);
		}
	}

	TT_Shutdown();

    ExitProcess(1);
}
note that I have changed "gdi.cpp" to show grayscale before:

Code: Select all

void SetGray(BITMAPINFO_8bpp & bmi)
{
	memset(bmi.bmiColors, 0, sizeof(bmi.bmiColors));

	for (int i=0; i<256; i++)
	{
		bmi.bmiColors[ i ].rgbRed = i;
		bmi.bmiColors[ i ].rgbGreen = i;
		bmi.bmiColors[ i ].rgbBlue = i;
	}
}
	SetGray(bi); // as defined in previous post.
	bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bi.bmiHeader.biPlanes = 1;
	bi.bmiHeader.biBitCount = 8;
	bi.bmiHeader.biCompression = BI_RGB;
	bi.bmiHeader.biSizeImage = ((((surface_width * 8) + 31) & ~31) >> 3) * surface_height;
	bi.bmiHeader.biWidth = surface_width;
	bi.bmiHeader.biHeight = -surface_height;	// note well
	bi.bmiHeader.biClrUsed = 256;
	bi.bmiHeader.biClrImportant = 256;

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

Re: Tracking Tools sample code

Post by beckdo »

dashesy,

We will get another sample together to help you and others who want to base work on the Tracking Tools API. I'll also make sure the next build of the Tracking Tools that is posted has a function that can change the camera's video mode, exposure, threshold, and illumination.

Down the roadmap a bit further, the TT API will pass a pointer to the camera object that will allow you to control every aspect of the camera settings.
dashesy
Posts: 33
Joined: Fri Mar 27, 2009 8:47 am
Location: Utah

Re: Tracking Tools sample code

Post by dashesy »

Doug,

Seems very promising!
Thnx
dashesy
Posts: 33
Joined: Fri Mar 27, 2009 8:47 am
Location: Utah

Re: Tracking Tools sample code

Post by dashesy »

Code: Select all

 TT_SetCameraSettings(0, 0, 240, 150, 4);
I added the above line to the code above and an empty buffer returned from TT_CameraFrameBuffer. BTW, The returned Boolean value from this function (which is not documented) is false.
Note that I have only one camera and that might be the reason running the markers example (as part of TT samples) crashes loading the project file.
While "Single Camera Tracking Module" available in TT2.0 software might not be still ready as an API, my code above is very minimal and without any tracking.

Please let me know if I am doing something wrong.
Thanks for any help
nabilgkhoury
Posts: 5
Joined: Mon Oct 26, 2009 1:16 pm

Re: Tracking Tools sample code

Post by nabilgkhoury »

Would be very nice to have a sample or two using the new API. Something similar to the Rigidbody sample, which opens existing settings, starts the cameras, prints out frame/trackable object information and then shuts down, would be much appreciated.

Many thanks.
Post Reply