-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
rs2::pipeline::stop() takes several seconds longer if more than 5 frames have been polled from the camera #13006
Comments
Hi @mattiasbax May I first ask about the specification of the computer / computing device that you are using, please? As the number of simultaneously active RealSense cameras attached to a computer is increased, the amount of the computer's resources that are consumed increases. It is therefore recommendable for a computer with 4 simultaneously active cameras attached to have an Intel Core i7 CPU or equivalent. May I also ask which method you used to install the librealsense SDK. If you built it from source code and used the RSUSB = true method then RSUSB is best suited to single camera applications, whilst a kernel-patched build of the SDK works best for multiple camera applications. The recommended camera firmware driver to use with SDK 2.54.2 is 5.15.1.0, as the 5.16.0.1 firmware is designed for the current latest librealsense SDK version 2.55.1. Kernel 6.6 is not currently supported by the SDK. The most recent supported version at the time of writing this is 6.5, and that support was introduced in the 2.55.1 SDK. If the SDK was installed with the RSUSB = true method though then the kernel version should not matter as an RSUSB build of the SDK bypasses the kernel. |
Hi Marty!
Just to clarify: Everything works as intended in terms of running multiple cameras at desired framerates and polling frames for each camera respectively. The only thing behaving inconsistently is the time it takes to close the camera pipelines. |
Are you automatically creating a separate pipeline for each attached camera like in the SDK's rs-multicam C++ multiple camera example program? |
Yes, that happens in the above example where we have a vector of structs (where each struct has it's own rs2::pipeline object) |
As poll_for_frames() is being used, there can be situations where you need to put the CPU to sleep for a time and specify for how long it should sleep, otherwise the CPU's percentage usage can max out at 100% of a single CPU core. #2219 (comment) has a multicam C++ example of code for putting the CPU to sleep when using poll_for_frames().
You coud verify whether the CPU is maxing out at 100% using an Ubuntu system monitoring tool such as htop. |
This has no affect, as the problem is not with poll_for_frames (or wait_for_frames for that matter) but that the time it takes to stop the camera pipeline is highly inconsistent |
I would usually not recommend using threads as they can make programs more complicated and increase the risk of instability compared to a non-threaded version of the code. However, it does appear to be an appropriate solution in your particular project. |
Using threads is not an option in this case as that would mean that all cameras would poll frames simultaneously which is not what I am interested of in this particular project. The threaded code example was to provide more debug data to the inconsistency happening within Do you have the possibility to compile the above program and run it on your end to see if you can replicate the inconsistencies? |
I am not able to compile and test code on my computer, unfortunately. I do apologize. Does it make any difference if you place an rs2_release_frame() command to release the frames on the line immediately before the pipe stop line? I believe that in your particular program the line would look like this:
Another approach may be to perform a hardware_reset() on all attached cameras instead of just one. #9287 (comment) has a multiple camera C++ reset script to iterate through all cameras. A reset takes about 2 seconds to complete, but is at least shorter than several seconds. |
Correct me if I'm wrong but since Adding a hardware reset to each camera had no effect on the longer pipeline stopping time. |
I am not familiar enough with structs and destructors to comment on the mechanics of releasing frames. I do apologize. Although using threads was a solution, you mentioned at #13006 (comment) that it would not be suitable for you because you do not wish to poll all cameras simultaneously. Are you aiming to turn individual cameras on and off and only poll one camera at a time in the set of four D415s in order to reduce the burden of processing multiple cameras simultaneously, please? If you are, then if you manually define the serial number of each of the four cameras in the script then you could enable and disable specific cameras instead of stopping all cameras at the same time. |
The problem is not with stopping the cameras in between polling of different cameras. |
The following suggestion is a little 'hacky' but you could test it to see whether it makes a difference. Immediately after the pipeline stop line, set a new configuration that makes sure that all active streams are disabled. Then start the pipeline again to apply the new config and disable all currently active streams. Then finally close the pipeline again in the hope that shutting down all streams released any trapped resources.
#12663 is an interesting discussion about 'hanging threads'. |
The first stop will take long time, the second stop will take short time, regardless of whether all the streams are disable. i.e.
Will give output: And that's regardless of whether disable_all_streams() is used or not. Since I need to stop the pipeline in order to disable all streams, and can't stop the pipeline before it is started, it's a bit of a catch 22 problem |
#13006 (comment) earlier in this discussion established that using threads provides a solution for the issue, but you stated that "using threads is not an option in this case as that would mean that all cameras would poll frames simultaneously which is not what I am interested of in this particular project". Could you provide further information please about why you do not want all cameras to poll frames simultaneously? Thanks! |
I have one camera each in the corner of a square, pointing towards the center. This means that there for each camera there is a camera on the opposite side looking directly towards it. I have noticed that the laser emitter from the opposing camera may cause the auto exposure to behave weirdly as it creates a very bright part of the image, which is why I'm capturing frames from one camera at a time with the other IR emitters turned of. I have also noticed better depth performance for this particular setup when only one IR emitter is turned on rather than having 4 emitters at a rather close distance which might oversaturate some pixels |
Multiple RealSense 400 Series cameras do not interfere with each other, and projecting multiple IR dot patterns can be beneficial for depth analysis of the scene because the denser the group of dots projected onto a surface because of the multiple overlapping dot patterns, the better the camera can analyze that area for depth information. The arrangement of cameras around a squared checkerboard at close range is also used by the RealSense SDK's box_dimensioner_multicam Python box measuring example project. That project works best when the cameras are around 0.5 meters from the board, with negative results when the cameras are nearer or further from the board. The IR light from the camera's emitter is most intense close to the lens, with its strength falling off as distance from the camera increases. So if cameras were positioned around a board at very close range then I can appreciate how that could create an intense pool of light on the board surface and the surrounding area. |
Hi @MartyG-RealSense, colleague of @mattiasbax here. I appreciate that you're looking for solutions and workarounds. To give some context, we've had an team of experienced developers working on this project for more than a year. The camera arrangement is subject to numerous design constraints and not something we can change like in a lab setup. We are fully aware that the cameras are on paper not supposed to interfere with each other, but they do. That might be a different discussion thread to follow up on. However, what @mattiasbax is reporting here is a likely bug in the SDK relating to |
Hi @jgrahn My computers are not set up with a development environment to compile and test programs as I am a Support Engineer. If you are using the cameras in the same location indoors with consistent artificial lighting and the cameras are not being moved then you could try disabling auto-exposure if you have not attempted this already so that the cameras use a fixed manual exposure value, in order to see whether this makes a difference to your multicam exposure problem. If disabling auto-exposure and using manual exposure does not resolve your issue then I will be pleased to highlight this case to developer members of my Intel RealSense colleagues for advice. |
Hi @mattiasbax and @jgrahn Does disabling auto-exposure and using a fixed manual exposure value resolve your multicam exposure issue, please? |
Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Issue Description
Hello,
I have a setup with 4x D415 cameras. I've noticed significant differences in execution time of
rs2::pipeline::stop()
and did some debugging to try find out what causes this.I have narrowed it down to that it is dependent on how many times I call
rs2::pipeline::poll_for_frames()
after starting the pipeline viars2::pipeline::start()
. For example, anything from 5 or less polled frames will cause stopping all 4 cameras <275ms, but more than 5 frames will cause stopping them take up to several seconds.I created a program that reproduces this behavior consistently (see below).
The image snippet show the different timing results for 10 pipeline stops for polling 5 and 6 frames, respectively.
Any idea what might be causing this behavior and how I could mitigate it?
Thanks!
/ M
The text was updated successfully, but these errors were encountered: