question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FPS change, a lot, depending on object distance from camera

See original GitHub issue

Describe the bug FPS change, a lot, depending on object distance from the camera. In the following video, you can see how the picam2.capture_array() slowdown when I change the object distance from the camera. This does not happen with "libcamera-hello -t 0.

Screen capture of issue: https://youtu.be/-fcGAsdIHT4

To Reproduce The used code is:

#!/usr/bin/python3

import time

import cv2
import numpy as np
from picamera2 import Picamera2

picam2 = Picamera2()
main = {"format": 'RGB888', "size": (640, 480)}
raw = {"format": "SRGGB10_CSI2P", "size": (1332, 990)}
config = picam2.preview_configuration(main, raw=raw)
picam2.configure(config)
picam2.start()

frame_cnt = 0
frame_fps = 0
frame_info_show = False

tfps1 = time.perf_counter()
while True:
    try:
        try:
            frame = picam2.capture_array()
        except:
            frame = None
        if frame is None:
            print('image not ready!')
            continue
        cv2.imshow('frame', frame)
        cv2.waitKey(1)
        if frame_info_show:
            frame_info_show = False
            print('FPS = {:5.2f}'.format(frame_fps))
        frame_cnt += 1
        tfps2 = time.perf_counter()
        if (tfps2 - tfps1) > 1.0:
            tfps3 = time.perf_counter()
            frame_fps = frame_cnt / (tfps2-tfps1)
            frame_cnt = 1
            tfps1 = tfps3
            frame_info_show = True

    except Exception as e:
        print(e)

Hardware : I’m using the latest Picamera2 and raspberry libcamera version on RPi 4B with IMX447 (motorized but not managed yet).

qem@raspberrypi:~ $ uname -a
Linux raspberrypi 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux

qem@raspberrypi:~ $ libcamera-hello --version
libcamera-apps build: 0dc5ea038c79 04-03-2022 (10:35:09)
libcamera build: v0.0.0+3544-22656360

qem@raspberrypi:~ $ pip list | grep picamera2
picamera2         0.2.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Tim-Brown-NZcommented, Aug 30, 2022

Hi, the problem is that the code above was written for an older version of the library and the thread has not been updated.
The preview_configuration method has been renamed create_preview_configuration.
Rename your call and you should be fine.

0reactions
UcefMountacercommented, Aug 30, 2022

Thank you, that helped me !!

Read more comments on GitHub >

github_iconTop Results From Across the Web

low fps when looking in a direction with many objects
But when I'm looking in a direction with many objects, the fps decreases to ~5 to 10 fps. I have set the objects...
Read more >
How to decide what fps camera is needed to track an object ...
First of all, transfer those m/s to a more understandable unit. 15m/s are 54km/h or 33.5mp/h Now you know that this speed actually...
Read more >
Frame Rate - an overview | ScienceDirect Topics
Frame rate [5]: Frame rate is the rate of change of frames on a display. ... While high frame rate cameras, as fast...
Read more >
Miniatures fps - Cinematography Mailing List
I am familiar with the equation for figuring out the camera frame rate for shooting miniature objects. The model we are to shoot...
Read more >
Real-Time Camera Tracking: When is High Frame-Rate Best?
Abstract. Higher frame-rates promise better tracking of rapid motion, but advanced real-time vision systems rarely exceed the standard 10–.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found