IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.55k stars 4.81k forks source link

How to access RS depth output without rendering to screen? #11767

Closed nataliesettles closed 1 year ago

nataliesettles commented 1 year ago
Required Info
Camera Model D435
Firmware Version 05.14.00.00
Operating System & Version Win 10
Platform PC
SDK Version 2.53.1.4623
Language unity

Issue Description

Hi - How can I output the texture/buffer of depth points from the rs camera without rendering an image to the screen? I'd like to use the points as a data source to inform an interactive response from the visualization I've built. I have successfully managed to use the stream of data from the RawImages in the TexturesDepthAndColor Scene in the Unity examples, but in the end, I don't want the depth images to render to the screen as a UI - I'd rather simply have a buffer or RenderTexture or similar that I can simply use as a data source. Is there a way you'd recommend doing this? - perhaps using the Depth or ColorizedDepth children of the RSDevice? Thanks!

MartyG-RealSense commented 1 year ago

Hi @nataliesettles In the TexturesDepthAnd Color scene, simply disabling the ColorImage and DepthImage children of the Canvas object by unticking them at the top of the right-hand Inspector panel will remove the depth and color frames from the screen so that the data is still being processed but they are not visually rendered.

image

nataliesettles commented 1 year ago

Yes - thanks. That wasn't quite where I was stuck, however, I just solved it moments ago.

I was having trouble accessing the texture data stream without using the RawImages to pass the texture stream between scripts. It turns out I simply needed to initialize a connection to the texture stream by binding a public setter method to a texture field in my own script to the textureBinding event in the RsStreamTextureRenderer script, and then referencing that newly bound field in the update method of my script in order to continue to get the updates to the stream.

MartyG-RealSense commented 1 year ago

It's great to hear that you achieved a solution. Thanks very much for sharing the details for the benefit of other RealSense Unity users who may be in a similar situation in future!