jmgomezpoveda / JGaze

Gaze library in Java
1 stars 1 forks source link

JavaCV FrameGrabber.getFrameRate() does not do anything useful #9

Open jmgomezpoveda opened 11 years ago

jmgomezpoveda commented 11 years ago

Detail in http://code.google.com/p/javacv/issues/detail?id=292

Calling getFrameRate() on a FFmpegFrameGrabber object, returns just the number that was previously set sith setFrameRate(), so, the requested framerate. If the video input does not support that framerate, getFrameRate() still returns the default value. Calling getFrameRate() on an OpenCVFrameGrabber object returns -1.

For example, we request 30 fps with setFrameRate, but a given webcam only supports 15 fps. getFrameRate returns 30 with FFmpegFG, and -1 with OpenCVFG.

I would expect this method to return the actual framerate set in the source (15 in the example).

jmgomezpoveda commented 11 years ago

http://code.google.com/p/javacv/issues/detail?id=292#c4

Action: Check what the ffmpeg program does, and if that does what you need, then to implement something similar in FFmpegFrameGrabber.getFrameRate()...

jmgomezpoveda commented 11 years ago

Workaround implemented as a recalculateFps method, which retrieves a few seconds of images, and calculates the average fps. However, sometimes it returns a slightly lower number. The higher the number of seconds, the more precise, but the longer the user will have to wait for initialization.