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

High variance in observed FPS in multi-camera setup #11321

Closed
michaelcukier opened this issue Jan 13, 2023 · 32 comments
Closed

High variance in observed FPS in multi-camera setup #11321

michaelcukier opened this issue Jan 13, 2023 · 32 comments

Comments

@michaelcukier
Copy link

michaelcukier commented Jan 13, 2023

Required Info
Camera Model D405
Firmware Version latest
Operating System & Version Ubuntu (for Jetson)
Kernel Version (Linux Only) 5.10
Platform Jetson AGX Orin
SDK Version latest
Language python
Segment robotics

Issue Description

I'm running three D405 using pyrealsense2. I'm running a simple python code that turns on the three cameras and count how many frames were received, and I sometimes get 4 FPS on average for all three cameras, and some other times 29 FPS, even though the setup is exactly the same. I don't understand why.

I tried running my code for a very long time (1 hour) twice, compared the results, and still got very different observed FPS. I am using the exact same three USB cables. I've also noticed that, very often, one camera has a significantly superior FPS compared to the two others.

What could be the reason(s) for this massive variance in FPS between each tests? Why is the observed FPS not stable at all? I could understand a difference of 1 or 2 FPS during each test, but a difference of 25 is really strange.

Note: when trying two or one D405, this problem seems to go away and the FPS is always at nearly 30FPS.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 13, 2023

Hi @michaelcukier As the number of RealSense cameras that are simultaneously active on the same computer is increased, the processing burden on the computer of handling those multiple cameras will increase, necessitating a higher-specification processor. For example, the Up Squared single-board computer has a 1.8 Ghz processor and can handle two RealSense 400 Series cameras simultaneously. The AGX Orin has a 2.2 Ghz processor.

For four simultaneously active cameras on the same computer, a processor equivalent to an Intel Core i7 or better is recommendable.

It is possible that whilst your board can handle two cameras simultaneously at almost 30 FPS, three cameras is a processing tipping-point where performance begins to degrade. You could test whether performance improves if the FPS for all cameras is reduced from 30 to 15.

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

Are you capturing only depth frames, or both depth and color frames please?

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 13, 2023

If both depth and color are enabled then there may sometimes be a drop in FPS. A fix for this can be to have auto-exposure enabled and have an RGB option called Auto-Exposure Priority disabled. This causes the RealSense SDK to try to enforce a constant FPS for both depth and color streams. A simple Python code snippet for disabling Auto-Exposure Priority can be found at #5885 (comment)

Edit: The D405 model does not have the Auto Exposure Priority setting, so that excludes that particular solution in this case.

If you are using manual exposure values then there can be a drop in FPS if exposure goes into a certain range, as described at #1957 (comment)

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

I added an update that the D405 model does not have the Auto Exposure Priority setting, so that excludes that particular solution in this case. As message edits do not go to your email, I will add additional thoughts to a new comment. :)

@MartyG-RealSense
Copy link
Collaborator

A way to confirm whether the FPS is slowing due to both depth and color being enabled would be to test with only depth frames and see if the third camera still has the FPS drop.

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

Thanks very much for the confirmation. If you need to have both depth and color enabled, please next test whether performance of the third camera improves if the FPS for all cameras is reduced from 30 to 15.

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

Are you able to reduce the resolution instead of the FPS in order to reduce the volume of data that needs to be processed?

@michaelcukier
Copy link
Author

michaelcukier commented Jan 13, 2023 via email

@MartyG-RealSense
Copy link
Collaborator

As you are using the color stream, potentially you could get some extra performance by building the librealsense SDK on your Jetson with CUDA support enabled if you have not done so already, as the SDK's CUDA support automatically offloads the processing of YUY to RGB color conversion from the Jetson's CPU to its Nvidia graphics GPU so the CPU does not have to do that color processing.

@michaelcukier michaelcukier changed the title Huge variance in observed FPS in multi-camera setup High variance in observed FPS in multi-camera setup Jan 17, 2023
@MartyG-RealSense
Copy link
Collaborator

Hi @michaelcukier Do you require further assistance with this case, please? Thanks!

@michaelcukier
Copy link
Author

Hi @MartyG-RealSense Thank you. I compiled using CUDA support and the problem still persist. GPU usage however seems rather low (around 30%) when running three cameras.

I just tried buying a PCIe USB 3.2 gen2 expansion card for my Jetson Orin and I connected a single D405 to it. It behaves strangely: the camera captures a couple frames and then freezes completely. Note that if I connect a USB webcam to the PCI it works fine. Any idea?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 23, 2023

Which Ubuntu version and JetPack version are you using with Orin, please? D405 has been able to be successfully used by RealSense users with Jetson Orin, Ubuntu 20.02 and JetPack 5.0.2, as described at #10416

@michaelcukier
Copy link
Author

I have the ones you have just mentioned.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 23, 2023

Thank you. Have you been able to test D405 successfully with other RealSense programs such as realsense-viewer?

Also, official D405 support was introduced in librealsense version 2.51.1, so 2.51.1 or newer should be used with D405.

@michaelcukier
Copy link
Author

Yes, with the realsense-viewer it seems to work fine. The librealsense I'm using is the latest one

@MartyG-RealSense
Copy link
Collaborator

Does the camera still freeze if used with the basic Python multiple camera script at #1735 (comment)

@michaelcukier
Copy link
Author

The camera freezes when used in single-camera and/or multi-camera setup. Again this is only when connected through a PCIe USB expansion card.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 23, 2023

It is difficult to advise about PCIe USB expansion cards as I have not used one for years, and it was on a desktop PC rather than a Jetson. On the USB expansion cards at that time though, they had an optional connector for linking the expansion board to the computer's power supply so that it could handle devices with high power draw instead of just low-draw devices such as keyboard and mouse. It would be worth checking whether your own card has some form of external power connector in case your expansion card is providing insufficient power to the RealSense camera for it to be able to operate.

@michaelcukier
Copy link
Author

Ive just check and it seems the max supply for my PCIe card on the USB-A port is 5W. Is this enough for a single d405 ?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 23, 2023

You should budget 2W for each RealSense camera. So if the card supplies 5W shared between all devices attached to it then it should be sufficient for a single D405 so long as there are not additional devices attached to the card that are drawing power.

@michaelcukier
Copy link
Author

Ok then we discard this problem, as in my tests the only device connected to the PCIe is a single D405.

@MartyG-RealSense
Copy link
Collaborator

What happens if you use realsense-viewer with the camera attached to the PCIe card?

@michaelcukier
Copy link
Author

It shows me the first frame and then freezes. I get a "no frame received" in red error after a bit.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 23, 2023

In a Jetson discussion about PCIe USB expansion cards at the link below, one commenter suggests adding pcie_aspm=off to the kernel command line in case the card has a problem with low power states.

https://forums.developer.nvidia.com/t/third-party-pci-e-usb-3-0-expansion-card-for-xavier-board/

@MartyG-RealSense
Copy link
Collaborator

Hi @michaelcukier Did the advice in the above comment make a difference, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Hi @michaelcukier Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

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