Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D435 FPS doesn't Exceed 40 #11967

Closed
bhomaidan1990 opened this issue Jul 5, 2023 · 2 comments
Closed

D435 FPS doesn't Exceed 40 #11967

bhomaidan1990 opened this issue Jul 5, 2023 · 2 comments

Comments

@bhomaidan1990
Copy link

bhomaidan1990 commented Jul 5, 2023

Required Info
Camera Model D435
Firmware Version 05.15.00.02
Operating System & Version Ubuntu 20.04
Kernel Version (Linux Only) 5.15.0-76-generic
Platform PC
SDK Version 2.50.0
Language Python
Segment Robot

Issue Description

I can't reach 60 fps as described in the datasheet, I'm connected using the original Cable to USB 3.1 port, using realsense-viewer it says ~ 58 - 59 FPS, but I can't reach the same FPS using python.

#!/usr/bin/env python3

import time
import numpy as np
import pyrealsense2.pyrealsense2 as rs

class RS_FPS:
    def __init__(self):
        # Start reading frames
        self.pipeline = rs.pipeline()
        config = rs.config()
        # RGB Stream USB 3.1 / FPI 60 doesn't work with USB 2.0
        config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 60) # bgr8/rgb8
        config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16,  60)

        # Start streaming
        self.pipeline.start(config)

        sensor = self.pipeline.get_active_profile().get_device().query_sensors()[1]
        sensor.set_option(rs.option.enable_auto_exposure, True)
        sensor.set_option(rs.option.auto_exposure_priority, False)

        align_to = rs.stream.color
        self.align = rs.align(align_to)

    def run(self):
        nb_frames = 0
        self.tic = time.time()
        while True:
            # Get frameset of color and depth
            frames = self.pipeline.wait_for_frames()

            # Align the depth frame to color frame
            aligned_frames = self.align.process(frames)

            # Get aligned frames
            # aligned_depth_frame is a 640x480 depth image
            aligned_depth_frame = aligned_frames.get_depth_frame() 
            color_frame = aligned_frames.get_color_frame()

            # Validate that both frames are valid
            if not aligned_depth_frame or not color_frame:
                continue
            
            depth_image = np.asanyarray(aligned_depth_frame.get_data())
            color_image = np.asanyarray(color_frame.get_data())

            self.toc = time.time()
            nb_frames += 1
            delta_time = self.toc - self.tic
            cur_fps = np.around(nb_frames / delta_time, 1)

            print("FPS: {}".format(cur_fps))

if __name__=="__main__":
    RS_FPS_ = RS_FPS()
    RS_FPS_.run()
@bhomaidan1990 bhomaidan1990 changed the title D435 FPS doesn D435 FPS doesn't Exceed 40 Jul 5, 2023
@MartyG-RealSense
Copy link
Collaborator

Hi @bhomaidan1990 Comparing frames to time to calculate an FPS value may not be accurate. At #7488 (comment) a RealSense team member provides technical information about how FPS is calculated in the RealSense SDK.

You could instead retrieve the camera metadata parameter ACTUAL_FPS

https://github.com/IntelRealSense/librealsense/blob/master/doc/frame_metadata.md#employing-metadata-attributes-in-demos

@bhomaidan1990
Copy link
Author

@MartyG-RealSense Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants