set frame rate

Hello,
I would like to measure the speed of small moving and jumping objects. The problem is that frame rate is not constant. The set_framerate command is no longer available. Is there a way to have a constant frame rate (i.e 10 FPS)?
Michel

Hi, you need to use the pyb.mills() command to track the elapsed milliseconds and then wait until a certain number are elapsed:

http://docs.openmv.io/library/pyb.html?highlight=millis#pyb.millis

To save power in a spin loop use: pyb — functions related to the board — MicroPython 1.15 documentation

Hello,
I have the same problem. I am using the Nicla Vision camera and I would like set a costant framerate (15 fps). Can you show me an example of code with pyb.mills() command as you have suggested?

Thank you

Hi, this is easy now.

sensor.set_framerate(15)

1 Like

Thank you for the answer. I have another question. I checked that with this command “sensor.set_framerate(15)”, when I print “clock.fps()” in the terminal, I read the right values. But when I save the video on my pc using the frame buffer (record button at the top right of the screen) I have noticed that the videos have another FPS. This FPS is not always the same but it varies (sometimes is for example 24.3 fps, or 32,26 fps) even if I use the same script (examples → "helloworld.py). I don’t know if exist another method to save the video on my pc whit a costant framerate of 15 FPS.

The PC re-records the frame buffer at 30 FPS. Use FFMPEG or etc to change the FPS from the PC.

There are desktop applications for this you can just use if the video is saved on the desktop.

1 Like