This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 621
C# Record and Playback APIs #822
Open
Brent-A
wants to merge
19
commits into
microsoft:develop
Choose a base branch
from
Brent-A:csharp-record
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
176e9e2
Added begining of record/playback for c#
Brent-A 3f2241e
Added record methods
Brent-A 6d1a588
Added minmial playback APIs
Brent-A 7209221
Completed Playback API
Brent-A 310287a
Added documentation
Brent-A ad6f6b6
Added some exception details
Brent-A c169698
Added tracing redirection to record
Brent-A f876d18
Enabled implicit stride in k4a_image_create
Brent-A 1797758
Removed default paramter in public API
Brent-A c6025bb
Added note on default parameters to standards.md
Brent-A 3768533
Merge branch 'issue-623' into csharp-record
Brent-A 972324a
Tests passing, and build config
Brent-A 594d672
Merge branch 'develop' of https://github.com/microsoft/Azure-Kinect-S…
Brent-A 0d50feb
Cleaned up C# style
Brent-A 09a6cf3
Merge branch 'develop' of https://github.com/microsoft/Azure-Kinect-S…
Brent-A 2b49c26
Style cleanup
Brent-A 05265bf
Added more options for native interop
Brent-A 5999e19
Added a few tests cases and fixed failures
Brent-A 3a3a059
Update src/csharp/Record/Exceptions/AzureKinectCreateRecordingExcepti…
Brent-A File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
src/csharp/Examples/Recording/Microsoft.Azure.Kinect.Sensor.Examples.Recording.csproj
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,52 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\k4a.props" /> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<AssemblyName>dotnetrecording</AssemblyName> | ||
|
||
<Platforms>x64;x86</Platforms> | ||
<RunCodeAnalysis>false</RunCodeAnalysis> | ||
<CodeAnalysisRuleSet>..\..\AzureKinectSensorSDK.ruleset</CodeAnalysisRuleSet> | ||
<OutputPath>$(BaseOutputPath)\$(AssemblyName)\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Record\Microsoft.Azure.Kinect.Sensor.Record.csproj" /> | ||
<ProjectReference Include="..\..\SDK\Microsoft.Azure.Kinect.Sensor.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="..\..\stylecop.json"> | ||
<Link>stylecop.json</Link> | ||
</AdditionalFiles> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(K4aBinaryDirectory)\k4a.dll"> | ||
<Link>k4a.dll</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="$(K4aBinaryDirectory)\k4a.pdb"> | ||
<Link>k4a.pdb</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="$(K4aBinaryDirectory)\k4arecord.dll"> | ||
<Link>k4arecord.dll</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="$(K4aBinaryDirectory)\k4arecord.pdb"> | ||
<Link>k4arecord.pdb</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
|
||
<!-- If the depth engine doesn't exist in the bin directory, it may be available in the PATH . | ||
It isn't needed for compilation, but only required at runtime when reading data from a live device. --> | ||
<Content Include="$(K4aBinaryDirectory)\depthengine_2_0.dll" Condition="Exists('$(K4aBinaryDirectory)\depthengine_2_0.dll')"> | ||
<Link>depthengine_2_0.dll</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
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,102 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using Microsoft.Azure.Kinect.Sensor; | ||
using Microsoft.Azure.Kinect.Sensor.Record; | ||
|
||
namespace Recording | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int frame = 0; | ||
|
||
if (args.Length < 1) | ||
{ | ||
Console.WriteLine("Please specify the name of an .mkv output file."); | ||
return; | ||
} | ||
|
||
string path = args[0]; | ||
|
||
try | ||
{ | ||
Console.WriteLine($"Recording from device to \"{path}\"."); | ||
|
||
DeviceConfiguration configuration = new DeviceConfiguration() | ||
{ | ||
CameraFPS = FPS.FPS30, | ||
ColorFormat = ImageFormat.ColorMJPG, | ||
ColorResolution = ColorResolution.R720p, | ||
DepthMode = DepthMode.NFOV_2x2Binned, | ||
SynchronizedImagesOnly = true | ||
}; | ||
using (Device device = Device.Open()) | ||
using (Recorder recorder = Recorder.Create(path, device, configuration)) | ||
{ | ||
|
||
device.StartCameras(configuration); | ||
device.StartImu(); | ||
|
||
recorder.AddImuTrack(); | ||
recorder.WriteHeader(); | ||
|
||
for (frame = 0; frame < 100; frame++) | ||
{ | ||
using (Capture capture = device.GetCapture()) | ||
{ | ||
recorder.WriteCapture(capture); | ||
Console.WriteLine($"Wrote capture ({capture.Color.DeviceTimestamp})"); | ||
try | ||
{ | ||
while (true) | ||
{ | ||
// Throws TimeoutException when Imu sample is not available | ||
ImuSample sample = device.GetImuSample(TimeSpan.Zero); | ||
|
||
recorder.WriteImuSample(sample); | ||
Console.WriteLine($"Wrote imu ({sample.AccelerometerTimestamp})"); | ||
} | ||
} | ||
catch (TimeoutException) | ||
{ | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
Console.WriteLine($"Wrote {frame} frames to output.mkv"); | ||
|
||
using (Playback playback = Playback.Open(@"output.mkv")) | ||
{ | ||
Console.WriteLine($"Tracks = {playback.TrackCount}"); | ||
Console.WriteLine($"RecordingLength = {playback.RecordingLength}"); | ||
|
||
for (int i = 0; i < playback.TrackCount; i++) | ||
{ | ||
string name = playback.GetTrackName(i); | ||
string codecId = playback.GetTrackCodecId(name); | ||
|
||
Console.WriteLine($" Track {i}: {name} ({codecId}) (builtin={playback.GetTrackIsBuiltin(name)})"); | ||
} | ||
Capture capture; | ||
while (null != (capture = playback.GetNextCapture())) | ||
{ | ||
Console.WriteLine($"Color timestamp: {capture.Color.DeviceTimestamp} Depth timestamp: {capture.Depth.DeviceTimestamp}"); | ||
} | ||
} | ||
|
||
} catch (AzureKinectException exception) | ||
{ | ||
Console.WriteLine(exception.ToString()); | ||
Console.WriteLine(); | ||
Console.WriteLine("Azure Kinect log messages:"); | ||
foreach (LogMessage m in exception.LogMessages) | ||
{ | ||
Console.WriteLine(m.ToString()); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright header.