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?
Problem with SampleClient example
-
- Posts: 10
- Joined: Tue May 07, 2013 8:00 am
Re: Problem with SampleClient example
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???
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???
-
- NaturalPoint Employee
- Posts: 199
- Joined: Tue Jun 24, 2008 2:01 pm
- Location: Corvallis, OR, USA
- Contact:
Re: Problem with SampleClient example
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
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