Problem with SampleClient example

NatNet, VRPN, TrackD, and Plugins
Post Reply
weifeng0715
Posts: 10
Joined: Tue May 07, 2013 8:00 am

Problem with SampleClient example

Post by weifeng0715 »

I want to know why there is frame lost as the frame number increase. Thanks.

For instance, I found the data in the file "Client-output" jump from Frame 3826 to Frame 3834. Is there any error there?
weifeng0715
Posts: 10
Joined: Tue May 07, 2013 8:00 am

Re: Problem with SampleClient example

Post by weifeng0715 »

If I comment out the code after


NatNetClient* pClient = (NatNetClient*) pUserData;

printf("Received frame %d\n", data->iFrame);


if(fp)
_WriteFrame(fp,data);


in the "void __cdecl DataHandler(sFrameOfMocapData* data, void* pUserData)" function, it seems working without losing frames?
Why???
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Problem with SampleClient example

Post by morgan »

The SampleClient outputs all packet data to the console window on the same thread as the data handler. If the console output gets behind (typical at 100 fps with a large data packet) then frames received by the client are dropped. This is normal behavior - the SampleClient is designed to be as simple and readable as possible, but not terribly efficient.

A more complete (and complex) example would typically only store the necessary data from the data packet in the callback handler and then return, which would prevent any frame drop. Processing the actually data would typically occur on a separate thread, esp if processing time exceeds frame time (e.g. 8ms @ 120), unless frame drop is the desired behavior when the processing chain gets behind.

hope this helps,

Morgan
Post Reply