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

wait_for_frames cannot be called if a callback was provided #7858

Closed
OneQuestion opened this issue Nov 25, 2020 · 12 comments
Closed

wait_for_frames cannot be called if a callback was provided #7858

OneQuestion opened this issue Nov 25, 2020 · 12 comments

Comments

@OneQuestion
Copy link


Required Info
Camera Model { D435i }
Firmware Version (2.40)
Operating System & Version {Ubuntu 16
Kernel Version (Linux Only)
Platform PC
SDK Version }
Language {C++ }
Segment

Issue Description

I am trying to use "motion" example and add depth frames. I tried adding to this example cfg.enable_stream(RS2_STREAM_DEPTH, 848, 480, RS2_FORMAT_Z16, 30);, but after adding auto frames = pipe.wait_for_frames(); I get terminate called after throwing an instance of 'rs2::wrong_api_call_sequence_error wait_for_frames cannot be called if a callback was provided error. How can I access the depth frames here?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Nov 26, 2020

Hi @OneQuestion I hope that the information in the link below will be helpful to you.

#2945

As the discussion in the above link mentions, the rs-callback C++ example program can provide guidance for using depth and IMU data in the same program.

https://github.com/IntelRealSense/librealsense/blob/master/examples/callback/

The program's notes state: "The default video configuration contains Depth and Color streams. If a device is capable to stream IMU data, both Gyro and Accelerometer are enabled by default".

@MartyG-RealSense
Copy link
Collaborator

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

@OneQuestion
Copy link
Author

OneQuestion commented Dec 3, 2020 via email

@MartyG-RealSense
Copy link
Collaborator

Are you experiencing the same error as before please?

terminate called after throwing an instance of 'rs2::wrong_api_call_sequence_error wait_for_frames cannot be called if a callback was provided

@OneQuestion
Copy link
Author

OneQuestion commented Dec 5, 2020 via email

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Dec 5, 2020

I researched your case further and found a past C++ case about adding depth to rs-motion where the RealSense user used the same cfg setup code for the depth stream that you did. Yet it was successful for them. The details of that case suggest that adding the cfg line was the only change that needed to be made to rs-motion.

#4185

As you mentioned earlier, it may be the use of the auto frames = pipe.wait_for_frames() line that is causing the problem with your particular script. It is not present in the original rs-motion.cpp script. The rs-motion script uses callbacks. In a link that RealSense team member ev-mp provides, he explains that callbacks are Asynchronous and wait_for_frames is Synchronous, and the two cannot be mixed together interchangeably.

#3817 (comment)

@OneQuestion
Copy link
Author

OneQuestion commented Dec 6, 2020

So I have to get frames in asynchronous mode? Should I use this callback method?

@MartyG-RealSense
Copy link
Collaborator

The impression that I get from the advice in #4185 (comment) is that you should only need to add the cfg statement for the depth stream. If you only add the cfg line for depth to rs-motion and add nothing else, does the program work for you please?

@OneQuestion
Copy link
Author

OneQuestion commented Dec 6, 2020 via email

@MartyG-RealSense
Copy link
Collaborator

I looked at your problem carefully. It would be best to refer your question to @ev-mp though, as asynchronous programming is outside of my knowledge.

@ev-mp Could you assist @OneQuestion regarding how to get depth frames on a modified rs-motion program with depth added via a cfg stream definition please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

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

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no new 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