librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Could I have a little tutorial on how to use the video feature? I want to display the video in a winforms picturebox if that’s possible ;)

Open jinxzzz opened this issue 7 years ago • 6 comments

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model { D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version Win10
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC/Raspberry Pi/ NVIDIA Jetson / etc..
SDK Version { legacy / 2.. }
Language {C#}
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

<Describe your issue / question / feature request / etc..>

jinxzzz avatar Feb 27 '19 07:02 jinxzzz

Hi @jinxzzz Did you look at cs-tutorial-2-capture, I think it is more or less what you are looking for.

dorodnic avatar Feb 27 '19 08:02 dorodnic

Hi @jinxzzz Did you look at cs-tutorial-2-capture, I think it is more or less what you are looking for.

Thanks for the quick response. I wrote the winform program by referring to the source code you said.But the source code is written in WPF.WPF is still different from winform in many ways.The winform program I wrote according to this source code does not show depth images. Could you help me check my program and provide me with a small demo to show depth images in picturebox controls?Thank you very much!

Here is my code:

           Pipeline  pipeline;
           pipeline = new Pipeline();
           Colorizer colorizer;
           colorizer = new Colorizer();

           var cfg = new Config();
           cfg.EnableStream(Intel.RealSense.Stream.Depth, 640, 480, Format.Any, 30);
           cfg.EnableStream(Intel.RealSense.Stream.Color, 1280, 720, Format.Rgb8);
           var pp = pipeline.Start(cfg);
           
           var frames = pipeline.WaitForFrames();
           
           var colorFrame = frames.ColorFrame.DisposeWith(frames);
           var depthFrame = frames.DepthFrame.DisposeWith(frames);
           var p = pp.GetStream(Intel.RealSense.Stream.Depth) as VideoStreamProfile;
           var img = new Bitmap(p.Width, p.Height, PixelFormat.Format24bppRgb);
            pictureBox1.Image = img;

jinxzzz avatar Feb 27 '19 08:02 jinxzzz

@RealSense-Customer-Engineering

jinxzzz avatar Mar 06 '19 06:03 jinxzzz

Problem with @jinxzzz's code isn't Winform\WPF related, it's that depth images aren't in a format compatible for display. The default depth format is Format.Z16, which is 16-bit linear depth in device units. You'll need to convert this for something that can be displayed, this is what the Colorizer processing block is for, it returns a color-mapped frame with Format.Rgb8.

ogoshen avatar Apr 01 '19 07:04 ogoshen


Hi jinxzzz,

Given what ogoshen mentioned, wonder if you have any update? Or do you still need help?

Thanks!


Hi jinxzzz,

If there is nothing else, this one will be closed soon.

Thanks!