Faster framerate

OpenCV, Python and other image processing questions
Post Reply
Michael93
Posts: 3
Joined: Sat Dec 14, 2019 12:12 pm

Faster framerate

Post by Michael93 » Sat Dec 28, 2019 9:43 am

Hello.

I am new in using stereopi and I am looking for the solution of the problem in my project in this forum :)

I have such a code written in Python that captures images from cameras :

camera = picamera.PiCamera(stereo_mode='side-by-side', sensor_mode=7, framerate=70)
camera.resolution = (320*2, 240)
time.sleep(2)
start = time.time()
stream = io.BytesIO()
for foo in camera.capture_continuous(stream, 'jpeg', burst=True):
img_counter += 1
if img_counter == 30:
FPS = (1.0 * img_counter) / (time.time() - start_time)
print("FPS: %0.2f" % FPS)
img_counter = 0
start_time = time.time()

Using this method I gather around 23 frames per second. Using Raspbian S.L.P. Image I observe the higher frequency of gathered frames? Is there any way to speed up the capturing process?

Best regards,
Michael

User avatar
Realizator
Site Admin
Posts: 356
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: Faster framerate

Post by Realizator » Sat Dec 28, 2019 12:34 pm

Hi Michael93,
Actually Python frames capture is a bottleneck. You can do some optimizations for this. For example, you can read this brilliant answer from the PiCamera developer here. I mean the second part of his answer concerning np.frombuffer section.

You see, we're preparing a new article now, concerning performance comparison of Python and C based code. In our C code we use piped transfer from the raspividyuv to our binary, and was able to get 88 FPS for the 1280x480 greyscale image. You can use similar approach to your Python script. Here is an an example of this pipe-based approach in this gist on a GitHub.
Eugene a.k.a. Realizator

Post Reply