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

Fix GetDistance() issue for SoftwareDevice in C# #12193

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions wrappers/csharp/Intel.RealSense/Sensors/SoftwareSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void AddVideoFrame(SoftwareVideoFrame f)
NativeMethods.rs2_software_sensor_on_video_frame(Handle, f, out error);
}

public void AddVideoFrame<T>(T[] pixels, int stride, int bpp, double timestamp, TimestampDomain domain, int frameNumber, VideoStreamProfile profile)
public void AddVideoFrame<T>(T[] pixels, int stride, int bpp, double timestamp, TimestampDomain domain, int frameNumber, VideoStreamProfile profile, float depthUnits = 0f)
{
// TODO: avoid copy by adding void* user_data to native methods, so we can pass GCHandle.ToIntPtr() and free in deleter
IntPtr hglobal = Marshal.AllocHGlobal(profile.Height * stride);
Expand All @@ -44,7 +44,8 @@ public void AddVideoFrame<T>(T[] pixels, int stride, int bpp, double timestamp,
timestamp = timestamp,
domain = domain,
frame_number = frameNumber,
profile = profile.Handle
profile = profile.Handle,
depth_units = depthUnits
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public class SoftwareVideoFrame
public TimestampDomain domain;
public int frame_number;
public IntPtr profile;
public float depth_units;
}
}
4 changes: 3 additions & 1 deletion wrappers/csharp/tutorial/software-dev/Window.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ public CaptureWindow()

depthData = depthData ?? new ushort[depthFrame.Width * depthFrame.Height];
depthFrame.CopyTo(depthData);
// Construct SW depth frame for SW depth sensor and initialize Depth Unit
depth_sensor.AddVideoFrame(depthData, depthFrame.Stride, depthFrame.BitsPerPixel / 8, depthFrame.Timestamp,
depthFrame.TimestampDomain, (int)depthFrame.Number, depth_profile);
depthFrame.TimestampDomain, (int)depthFrame.Number, depth_profile, realDepthSensor.DepthScale);

colorData = colorData ?? new byte[colorFrame.Stride * colorFrame.Height];
colorFrame.CopyTo(colorData);
// Construct SW color frame for SW color sensor
color_sensor.AddVideoFrame(colorData, colorFrame.Stride, colorFrame.BitsPerPixel / 8, colorFrame.Timestamp,
colorFrame.TimestampDomain, (int)colorFrame.Number, color_profile);
}
Expand Down
Loading