0

I'm trying to read frames from a webcam and analyze them in realtime, but since my function AnalyzeFrame() is faster than the framerate, it ends up pulling the same frame 1-4 times in a row, messing up my data. Here's basically what I'm running.

import imageio

cam = imageio.get_reader('<video0>', fps=30)

while not cam.closed:
    print(AnalyzeFrame(cam.get_next_data()))

A few notes: My webcam should be able to handle 30fps, but I'm averaging 12-14 fps. I've timed each individual process and there's very little regularity to the framerate. Some frames only get analyzed once, because they're in the buffer for 20 or so milliseconds. Others get analyzed 4 times over a span of 100+ ms. Is there something in my code that's causing this framerate problem?

Nick Porter
  • 163
  • 8

1 Answers1

1

From what I understood from some tests, when you call get_next_data() it is then that your script grabs the frame from the webcam. Therefore, setting a fps is useless.

To find the reason why you cannot reach 30 fps should reside in the time your function AnalyzeFrame takes.

Seanny123
  • 8,776
  • 13
  • 68
  • 124