Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

C# Record and Playback APIs (SDK binary compatible version) #1711

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Data science would like to know about all schema changes Engineering plan to make to SQL databases. This automates the process and is intended to be used by Data Science as a FYI of an incoming change as opposed to a review.
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
* @vald-green/code-owners-harald
*.sql @vald-green/code-owners-harald @vald-green/code-owners-data-science
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
-->
## Fixes #

Related DevOps Ticket: AB#<INSERT_TICKET_NUMBER>

### Description of the changes:
-
-
Expand Down
109 changes: 56 additions & 53 deletions docs/releasing.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/k4arecord/playback.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ K4ARECORD_EXPORT void k4a_playback_data_block_release(k4a_playback_data_block_t
*
* \remarks
* The first call to k4a_playback_get_next_imu_sample() after k4a_playback_seek_timestamp() will return the first imu
* sample with a timestamp greter than or equal to the seek time.
* sample with a timestamp greater than or equal to the seek time.
*
* \remarks
* The first call to k4a_playback_get_previous_imu_sample() after k4a_playback_seek_timestamp() will return the first
Expand Down
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>
102 changes: 102 additions & 0 deletions src/csharp/Examples/Recording/Program.cs
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());
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@
<Link>k4a.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(K4aBinaryDirectory)\depthengine_2_0.dll">
<!-- 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
<Link>k4a.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(K4aBinaryDirectory)\depthengine_2_0.dll">
<!-- 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>
Expand Down
Loading