PS3Eye FPS measuring and real framerate
Posted: 01 March 2011 07:50 AM   [ Ignore ]
New Member
Rank
Total Posts:  2
Joined  2011-01-18

Hi. I tried to determine, what real fps I can get from PS3Eye, so I wrote this app:

const int framesMultiplier = 5;

void capture(int camIndex, int freq, CLEyeCameraResolution res) {
    GUID cameraGUID 
= CLEyeGetCameraUUID(camIndex);
    
CHAR windowName[256]; strcpy_s(windowName, "Capture Window");
    
int w, h, frame = 0;
    
unsigned __int64 start = 0, end = 0, QPF = 0;
    
float time = 0, realFPS = 0;
    
IplImage *pCapImage;
    
CLEyeCameraInstance cam = CLEyeCreateCamera(cameraGUID, CLEYE_COLOR_RAW, res, freq);
    
CLEyeCameraGetFrameDimensions(cam, w, h);
    
pCapImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 4);
    
CLEyeCameraStart(cam);
    
QueryPerformanceCounter((PLARGE_INTEGER)&start;);
    
PBYTE pCapBuffer; cvGetImageRawData(pCapImage, &pCapBuffer;);
    while(
frame != freq*framesMultiplier) {    
        CLEyeCameraGetFrame
(cam, pCapBuffer, 2000);
        
cvShowImage(windowName, pCapImage);
        
frame++;
        if (
cvWaitKey(10) == 0x1b) {break;}
    }
    QueryPerformanceCounter
((PLARGE_INTEGER)&end;);
    
QueryPerformanceFrequency((PLARGE_INTEGER) &QPF;);
    
time = (float)(end-start)/(float)QPF;
    
realFPS = (freq*framesMultiplier)/time;
    
cout << "Time for test: " << time << endl;
    
cout << "FPS: " << realFPS << endl;
    
CLEyeCameraStop(cam);
    
CLEyeDestroyCamera(cam);
    
cvReleaseImage(&pCapImage;);
    
cam = NULL;
    
cvDestroyWindow(windowName);
}

int _tmain
(int argc, _TCHAR* argv[]) {
    
for (int i = 0; i < CLEyeGetCameraCount(); i++) {
        capture
(i, 75, CLEYE_VGA);
    
}
    _getch
();
    return 
0;
} 

Then I start app with different freq and res. Thing I don’t really get is that I receive a maximum 63,5 FPS on both VGA and QVGA resolution. This means it’is not a USB bandwidth problem. PS3Eye don’t support higher FPS or it’s driver trouble, or it’s a my app trouble?

App shows FPS correctly, if I choose freq (15, 30, 50) for VGA:

15 Hz VGA: Time for test: 5.03177 FPS: 14.9053
30 Hz VGA
: Time for test: 5.04248 FPS: 29.7472
40 Hz VGA
: Time for test: 6.03324 FPS: 33.1497
50 Hz VGA
: Time for test: 5.03597 FPS: 49.6429
60 Hz VGA
: Time for test: 5.18322 FPS: 57.8791
75 Hz VGA
: Time for test: 5.9171  FPS: 63.3756 

On 40, 60 and 75 Hz frames are loses.

Then I change main cycle like this:

for (int i = 30; i < 100; i++) {
    cout 
<< "Set frequency to " << i << " hz:" << endl;
    
capture(0, i, CLEYE_VGA);
} 

Result was weird (not all results are shown):

Set frequency to 33 hz: Time for test: 2.02071 FPS: 32.6618
Set frequency to 34 hz
: Time for test: 2.07368 FPS: 32.7919
Set frequency to 35 hz
: Time for test: 2.1341  FPS: 32.8007
Set frequency to 36 hz
: Time for test: 1.96116 FPS: 36.713
Set frequency to 39 hz
: Time for test: 2.3781  FPS: 32.7994
Set frequency to 40 hz
: Time for test: 2.43241 FPS: 32.8893
Set frequency to 44 hz
: Time for test: 1.99173 FPS: 44.1826
Set frequency to 47 hz
: Time for test: 2.12689 FPS: 44.1959
Set frequency to 48 hz
: Time for test: 1.95644 FPS: 49.0686
Set frequency to 55 hz
: Time for test: 2.05889 FPS: 53.4269
Set frequency to 56 hz
: Time for test: 2.02461 FPS: 55.3194
Set frequency to 60 hz
: Time for test: 2.08597 FPS: 57.5273
Set frequency to 70 hz
: Time for test: 2.58228 FPS: 54.2157
Set frequency to 71 hz
: Time for test: 2.25962 FPS: 62.8425
... From 72 to 99 Hz ~ 63 FPS 

There are a loses on QVGA resolution on 33, 38-39, 46, 55 and other frequencies and also on 75, 100 and 125 Hz real FPS is ~63

In the end, I’ve try FRAPS to confirm this result, and it was exactly the same (only in integer values, not float).

Profile
 
 
Posted: 10 March 2011 10:02 AM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  7
Joined  2010-11-03

One obvious problem: cvWaitKey(10). This locks your thread for 10 ms. 60hz is a period of 16ms, so it’s clear this is causing the frame rate to max out at 62hz.

Profile
 
 
Posted: 12 March 2011 10:25 PM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  2
Joined  2011-01-18

Wish you were right, but changing to cvWaitKey(1) don’t resolve problem. Actually, nothing’s happen.

Profile
 
 
 
 


RSS 2.0     Atom Feed