- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1.Background:
(1)My environment included: vs 2015, c# , wpf project, RealSense SDK2.12, D435 device, win 10 OS
(2)I rebuilt the tutorials 1,2,3 in the c# wrapper SDK2 samples to display depth and color images, that is ok.
(3)I modified the FrameSet.cs to display the infrared stream, that is ok, the snip code is as following :
(add in FrameSet.cs)
public VideoFrame InfraredFrame {
get {
foreach (var frame in this) {
if (frame.Profile.Stream == Stream.Infrared)
return frame as VideoFrame;
frame.Dispose();
}
return null;
}
}
(tutorial-2)
(in UploadImage function)
PixelFormats.Rgb24-->PixelFormats.Gray8
(in CaptureWindow function)
cfg.EnableStream(Stream.Infrared, Format.Y8);
var infreared_frame = frames.InfraredFrame;
UploadImage(imgInfrared, infreared_frame);
2.My Question: How to modify program to show infrared data in c# wrapper SDK2 tutorial-3
I modified the tutorial-3 as the following snip code, but it don't work.
(in ProcessingWindow function)
cfg.EnableStream(Stream.Infrared, Format.Y8);
(in block.Start)
var infreared_frame = FramesReleaser.ScopedReturn(releaser, frames.InfraredFrame);
UploadImage(imgInfrared, infreared_frame);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for being patient with us while we worked through this program. Before you modify any code, please make sure to update to the latest RealSense SDK (build 2.15.0). Below are the modifications to the code. Should you need any clarifications, please let me know.
Add to Frameset.cs (add after public VideoFrame ColorFrame function):
public VideoFrame InfraredFrame
{
get
{
return FirstOrDefault(Stream.Infrared);
}
}
Remove from Window.xaml:
Add to Window.xaml instead:
Add to Window.xaml.cs (add after private void UploadImage(Image img, VideoFrame frame) funtion):
private void UploadGreyscaleImage(Image img, VideoFrame frame)
{Dispatcher.Invoke(new Action()) =>
{if (frame.Width == 0) return;
var bytes = new byte[frame.Stride * frame.Height];
frame.CopyTo(bytes);
var bs = BitmapSource.Create(frame.Width, frame.Height,300, 300,
PixelFormats.Gray8,
null,
bytes,
frame.Stride);
var imgSrc = bs as ImageSource;img.Source = imgSrc;}));}
Add to window.xaml.cs (add after line cfg.EnableStream(Stream.Depth, 640, 480);) :
cfg.EnableStream(Stream.Infrared, Format.Y8);
Add to window.xaml.cs (add after line VideoFrame color = FramesReleaser.ScopedReturn(releaser, frames.ColorFrame);) :
VideoFrame ir = FramesReleaser.ScopedReturn(releaser, frames.InfraredFrame);
Remove from window.xaml.cs:
var res = src.AllocateCompositeFrame(releaser, depth, color);
& replace it with:
var res = src.AllocateCompositeFrame(releaser, depth, color, ir);
Add to window.xaml.cs (after line var color_frame = FramesReleaser.ScopedReturn(releaser, frames.ColorFrame); ):
var ir_frame = FramesReleaser.ScopedReturn(releaser, frames.InfraredFrame);
Add to window.xaml.cs (after line UploadImage(imgColor, color_frame); ):
UploadGreyscaleImage(imgIr, ir_frame);
Regards, Sahira
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello qajhsieh,
Thank you for your interest in the Intel RealSense Technology.
We have received your query. Let me try to replicate and get back to you with my findings.
Thank you very much in advance,
Casandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you so much for being patient with us while we work through your case. I am working on modifying Example 3 of the C# examples to stream infrared. I will get back to you as soon as I've found a working solution.
Again, thank you for your patience.
Regards,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for being patient with us while we worked through this program. Before you modify any code, please make sure to update to the latest RealSense SDK (build 2.15.0). Below are the modifications to the code. Should you need any clarifications, please let me know.
Add to Frameset.cs (add after public VideoFrame ColorFrame function):
public VideoFrame InfraredFrame
{
get
{
return FirstOrDefault(Stream.Infrared);
}
}
Remove from Window.xaml:
Add to Window.xaml instead:
Add to Window.xaml.cs (add after private void UploadImage(Image img, VideoFrame frame) funtion):
private void UploadGreyscaleImage(Image img, VideoFrame frame)
{Dispatcher.Invoke(new Action()) =>
{if (frame.Width == 0) return;
var bytes = new byte[frame.Stride * frame.Height];
frame.CopyTo(bytes);
var bs = BitmapSource.Create(frame.Width, frame.Height,300, 300,
PixelFormats.Gray8,
null,
bytes,
frame.Stride);
var imgSrc = bs as ImageSource;img.Source = imgSrc;}));}
Add to window.xaml.cs (add after line cfg.EnableStream(Stream.Depth, 640, 480);) :
cfg.EnableStream(Stream.Infrared, Format.Y8);
Add to window.xaml.cs (add after line VideoFrame color = FramesReleaser.ScopedReturn(releaser, frames.ColorFrame);) :
VideoFrame ir = FramesReleaser.ScopedReturn(releaser, frames.InfraredFrame);
Remove from window.xaml.cs:
var res = src.AllocateCompositeFrame(releaser, depth, color);
& replace it with:
var res = src.AllocateCompositeFrame(releaser, depth, color, ir);
Add to window.xaml.cs (after line var color_frame = FramesReleaser.ScopedReturn(releaser, frames.ColorFrame); ):
var ir_frame = FramesReleaser.ScopedReturn(releaser, frames.InfraredFrame);
Add to window.xaml.cs (after line UploadImage(imgColor, color_frame); ):
UploadGreyscaleImage(imgIr, ir_frame);
Regards, Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for Sahira.
I still get ir_frame=null when I call UploadGreyscaleImage(imgIr, ir_frame)
(1)My environment: vs 2015 community, c# , wpf project, RealSense SDK2.15, D435 device, win 10 OS
(2)I changed sdk to 2.15 version
(3)I modified according to your suggestion and modified line 33 in Helpers.cs by
if(o!=null)o.Dispose();
(4)My project files are as follows: https://drive.google.com/file/d/1NH-1TySv6fQV2VYX8HPT44IfwtgWK0fX/view?usp=sharing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I apologize for giving you the wrong SDK version. The latest release is actually 2.16.0 and can be downloaded directly from the RealSense GitHub page here:
https://github.com/IntelRealSense/librealsense
This should fix all the error you're getting, and you shouldn't need to modify anything in Helpers.cs.
Regards,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are right, I changed SDK to 2.16 version and it correctly displays the infrared frame.
Thank you very much.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page