FPS dropped from 100 to 64 to 50

Post Reply
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

FPS dropped from 100 to 64 to 50

Post by hpcv »

I'm still playing around with the RigidBody-Sample (see also this other topic) but now I've run into a different problem.

At first, I got 100 fps with rigid body data in all of the frames, and I saw that it was good.

Then, after some work (including a new calibration), I suddenly only got 64 fps. Hardly fluctuating, 64 plus or minus 0.1.

The Rigid Body Tool itself still ran at around 100 fps. I tried several things including putting back my old calibration file, unplugging and replugging the cameras, recalibrating again, starting and stopping the Calibration and RB tools, and changing the Illumination and Exposure in the calibration file. At a certain point, I was back at 100 fps, but for an old (now invalid) calibration file, and when I put back the new (valid) one I was back at 64 fps and couldn't get back to 100 even with the old calibration file.

Then I unplugged and replugged the cameras once more, and suddenly I was at... 50 fps.

Another replug, back at 64. Haven't seen 100 since.

All this time, the RB tool itself happily runs at 100 fps. The RB API has no way to set FPS. What is going on? How do I prevent or fix this weird behaviour?
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: FPS dropped from 100 to 64 to 50

Post by hpcv »

Discovered something more... when I enable VRPN with RB_StreamVRPN, then the framerate goes up from 64 to 100 as soon as a client connects, and drops back to 64 when the client disconnects. :confused:
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: FPS dropped from 100 to 64 to 50

Post by beckdo »

So you're using the RB NPRigidBody.DLL to fetch frames directly through the API and it's dropping to 64FPS?
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: FPS dropped from 100 to 64 to 50

Post by hpcv »

Yes. Unless I tell the API to open up a VRPN port and a client is listening.

To measure the framerate, I use the Windows API function QueryPerformanceCounter, which is highly accurate. I issue Sleep(1) on each loop iteration and I have tried to vary this value.

Here's the relevant part of the program (based, as I said, on the RigidBody-Sample). Not the most pretty code I've ever produced, but it's mainly for testing anyway:

Code: Select all

// Error codes are not defined in NPRigidBody.h...
#define NPRESULT_NOFRAME 14

// Inside main():

    LARGE_INTEGER ticksPerSec, prevTicks;
    QueryPerformanceFrequency(&ticksPerSec);
    QueryPerformanceCounter(&prevTicks);
    double prevSecs = (double)prevTicks.QuadPart / ticksPerSec.QuadPart;
    int totalFrames = 0, lastTotalFrames = 0;
    double fps = 0;

    while(!_kbhit())
    {
        NPRESULT result = RB_GetLatestFrame();

        if (result == NPRESULT_SUCCESS)
        {
            LARGE_INTEGER ticks;
            QueryPerformanceCounter(&ticks);
            double secs = (double)ticks.QuadPart / ticksPerSec.QuadPart;

            // ...
            // Rigid body reading and printing stuff here...
            // ...

            ++totalFrames;

            if (secs - prevSecs >= 1) {
                fps = (totalFrames - lastTotalFrames) / (secs - prevSecs);
                lastTotalFrames = totalFrames;
                prevSecs = secs;
                printf("%f fps\n", fps);
            }
        } else if (result != NPRESULT_NOFRAME) {
            printf("Error %d: %s\n", result, RB_GetResultString(result));
        }
        Sleep(1);
    }
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: FPS dropped from 100 to 64 to 50

Post by hpcv »

Any updates on this? Thanks :)
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: FPS dropped from 100 to 64 to 50

Post by beckdo »

Yes, change your code from:

NPRESULT result = RB_GetLatestFrame();

to this:

NPRESULT result = RB_GetNextFrame();
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: FPS dropped from 100 to 64 to 50

Post by hpcv »

Doesn't help, sorry :(
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: FPS dropped from 100 to 64 to 50

Post by beckdo »

Ok, if this is possible, please send your project (or just the natualpoint portion) to support, and I'll take a closer look at it.
Post Reply