-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #8860 from SergeySPF: C# example for pose stream (for T265 device)
- Loading branch information
Showing
5 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required( VERSION 3.8.0 ) | ||
|
||
project(cs-tutorial-5-pose) | ||
|
||
add_executable(${PROJECT_NAME} | ||
Program.cs | ||
Properties/AssemblyInfo.cs | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v${DOTNET_VERSION_EXAMPLES}") | ||
# set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE TRUE) | ||
|
||
add_dependencies(${PROJECT_NAME} Intel.RealSense) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES | ||
"System" | ||
) | ||
|
||
set_target_properties (${PROJECT_NAME} PROPERTIES | ||
FOLDER Wrappers/csharp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
|
||
namespace Intel.RealSense | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
using (var ctx = new Context()) | ||
{ | ||
DeviceList devices = ctx.QueryDevices(); | ||
if (devices.Count == 0) | ||
{ | ||
Console.WriteLine("RealSense devices are not connected."); | ||
return; | ||
} | ||
|
||
using (var pipeline = new Pipeline(ctx)) | ||
using (var config = new Config()) | ||
{ | ||
// Add pose stream | ||
config.EnableStream(Stream.Pose, Format.SixDOF); | ||
// Start pipeline with chosen configuration | ||
using(var profile = pipeline.Start(config)) | ||
using (var streamprofile = profile.GetStream(Stream.Pose).As<PoseStreamProfile>()) | ||
{ | ||
Console.WriteLine($"\nDevice : {profile.Device.Info[CameraInfo.Name]}"); | ||
Console.WriteLine($" Serial number: {profile.Device.Info[CameraInfo.SerialNumber]}"); | ||
Console.WriteLine($" Firmware version: {profile.Device.Info[CameraInfo.FirmwareVersion]}"); | ||
Console.WriteLine($" Pose stream framerate: {streamprofile.Framerate}\n"); | ||
} | ||
|
||
while (true) | ||
{ | ||
// Wait for the next set of frames from the camera | ||
using (FrameSet frameset = pipeline.WaitForFrames()) | ||
// Get a frame from the pose stream | ||
using (PoseFrame frame = frameset.PoseFrame) | ||
{ | ||
// Get pose frame data | ||
Pose data = frame.PoseData; | ||
|
||
// Print the x, y, z values of the translation, relative to initial position | ||
Console.Write("\r" + new String(' ', 80)); | ||
Console.Write("\rDevice Position: {0} {1} {2} (meters)", data.translation.x.ToString("N3"), data.translation.y.ToString("N3"), data.translation.z.ToString("N3")); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
wrappers/csharp/cs-tutorial-5-pose/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Intel(R) RealSense(TM) SDK C# Wrapper Tutorial-5")] | ||
[assembly: AssemblyDescription("Intel(R) RealSense(TM) SDK C# Wrapper Examples")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Intel(R) Corporation")] | ||
[assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK C# Wrapper")] | ||
[assembly: AssemblyCopyright("Copyright © 2021, Intel Corporation. All rights reserved")] | ||
[assembly: AssemblyTrademark("Intel(R) RealSense(TM)")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("71c85ee0-c7c2-4e2e-8020-6af818537a14")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration> |