-
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
Manual frameset creation #5847
Comments
There was a previous case in 2019 where someone tried to create framesets manually using software device. Their work may provide a useful reference for you. https://support.intelrealsense.com/hc/en-us/community/posts/360037090133-Construct-Frameset-Object |
Hi @jc211 @MartyG-RealSense std::vector<rs2::frame> bundle;
rs2::processing_block bundler([&](rs2::frame f, rs2::frame_source& src) {
bundle.push_back(f);
if (bundle.size() == 2)
{
auto fs = src.allocate_composite_frame(bundle);
src.frame_ready(fs);
bundle.clear();
}
});
rs2::frame_queue q;
bundler.start(q); Use like this: bundler.invoke(f.get_depth_frame());
bundler.invoke(f.get_color_frame());
rs2::frameset fs = q.wait_for_frame(); In either of the methods you need some object to own any frames you want to create (either software device or processing block). This is because all frames in the SDK are recycled for performance reasons, so they must be part of some larger class. |
@dorodnic Thanks, that works! |
Hi! Can this part of codes be transformed into python language? |
Hi @wangbz98 The custom processing block is supported in Python. The official pyrealsense2 documentation for this function is in the link below. |
THX! But I'm not able to rewrite it with python, could you please help me? |
I researched your question carefully but there are no scripting references available for processing_block on Python other than the documentation page that I linked to, unfortunately. |
Hi @MartyG-RealSense , I would also like to use the custom processing block example in Python. I tried to translate it, but I can't get it to work. Here's the script: import pyrealsense2 as rs
def bundler_callback(f, src):
print('bundler function called')
bundle.append(f)
if len(bundle) == 2:
fs = src.allocate_composite_frame(bundle)
src.frame_ready(fs)
bundle.clear()
pipe = rs.pipeline()
cfg = rs.config()
cfg.enable_device_from_file('stairs.bag')
pipe.start(cfg)
fs = pipe.wait_for_frames()
bundle = list()
bundler = rs.processing_block(bundler_callback)
q = rs.frame_queue()
bundler.start(q)
bundler.invoke(fs.get_color_frame())
bundler.invoke(fs.get_depth_frame())
fs = q.wait_for_frame() And here's a link to the sample file I used: |
Hi @DonLuyendijk There are not any references about custom processing blocks in Python that I can point you to. Looking at your script though, I would suspect that you may need to place the name of your defined callback within the pipe start instruction's brackets. A Python example of this is demonstrated in a script at #5417 For example: pipe.start(cfg, bundler_callback) |
Hi,
I have one depth frame and one color frame. I want to create a frameset myself of these two. Is this possible?
The text was updated successfully, but these errors were encountered: