Skip to content

Commit

Permalink
Switching to version 0.9.3 of Azure Kinect Body Tracking SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
bibigone committed Sep 21, 2019
1 parent 14934b7 commit 333fd8f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 38 deletions.
28 changes: 7 additions & 21 deletions K4AdotNet.Samples.Wpf.BodyTracker/BodyIndexMapTransformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ namespace K4AdotNet.Samples.Wpf.BodyTracker
internal sealed class BodyIndexMapTransformation : IDisposable
{
private readonly Transformation transformation;
private readonly Image bodyIndexMapCustom8;
private readonly Image transformedDepthMap;
private readonly Image transformedBodyIndexMap;

public BodyIndexMapTransformation(ref Calibration calibration)
{
transformation = new Transformation(ref calibration);
var depthWidth = calibration.DepthMode.WidthPixels();
var depthHeight = calibration.DepthMode.HeightPixels();
bodyIndexMapCustom8 = new Image(ImageFormat.Custom8, depthWidth, depthHeight);
var colorWidth = calibration.ColorResolution.WidthPixels();
var colorHeight = calibration.ColorResolution.HeightPixels();
transformedDepthMap = new Image(ImageFormat.Depth16, colorWidth, colorHeight);
Expand All @@ -25,7 +21,6 @@ public BodyIndexMapTransformation(ref Calibration calibration)
public void Dispose()
{
transformation.Dispose();
bodyIndexMapCustom8.Dispose();
transformedDepthMap.Dispose();
transformedBodyIndexMap.Dispose();
}
Expand All @@ -37,24 +32,15 @@ public unsafe Image ToColor(Image depthMap, Image bodyIndexMap)

// Object can be disposed from different thread,
// thus it is worth to keep references to images while we're working with their buffers
using (var bodyIndexMapCustom8Ref = bodyIndexMapCustom8.DuplicateReference())
using (var transformedDepthMapRef = transformedDepthMap.DuplicateReference())
using (var transformedBodyIndexMapRef = transformedBodyIndexMap.DuplicateReference())
{
// Custom format -> Custom8 format
// See issue https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/704
Buffer.MemoryCopy(
bodyIndexMap.Buffer.ToPointer(), bodyIndexMapCustom8Ref.Buffer.ToPointer(),
bodyIndexMapCustom8Ref.SizeBytes, bodyIndexMap.SizeBytes);
transformation.DepthImageToColorCameraCustom(
depthMap, bodyIndexMap,
transformedDepthMapRef, transformedBodyIndexMapRef,
TransformationInterpolation.Nearest, BodyTracking.BodyFrame.NotABodyIndexMapPixelValue);

using (var transformedDepthMapRef = transformedDepthMap.DuplicateReference())
using (var transformedBodyIndexMapRef = transformedBodyIndexMap.DuplicateReference())
{
transformation.DepthImageToColorCameraCustom(
depthMap, bodyIndexMapCustom8Ref,
transformedDepthMapRef, transformedBodyIndexMapRef,
TransformationInterpolation.Nearest, BodyTracking.BodyFrame.NotABodyIndexMapPixelValue);

return transformedBodyIndexMapRef.DuplicateReference();
}
return transformedBodyIndexMapRef.DuplicateReference();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions K4AdotNet/BodyTracking/NativeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ internal static class NativeApi
{
public const int MAX_TRACKING_QUEUE_SIZE = 3;

// #define K4ABT_DEFAULT_TRACKER_SMOOTHING_FACTOR 0.5f
// #define K4ABT_DEFAULT_TRACKER_SMOOTHING_FACTOR 0.0f
/// <summary>The default tracker temporal smoothing factor.</summary>
public const float DEFAULT_TRACKER_SMOOTHING_FACTOR = 0.5f;
public const float DEFAULT_TRACKER_SMOOTHING_FACTOR = 0.0f;

// K4ABT_EXPORT k4a_result_t k4abt_tracker_create(const k4a_calibration_t* sensor_calibration,
// k4abt_tracker_configuration_t config,
Expand Down
4 changes: 2 additions & 2 deletions K4AdotNet/Sdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public static class Sdk
public const string BODY_TRACKING_DLL_NAME = "k4abt";

/// <summary>Expected version of Body Tracking runtime. This version of K4AdotNet assembly is built and tested against this version of Body Tracking.</summary>
public static readonly Version BODY_TRACKING_EXPECTED_VERSION = new Version(0, 9, 2);
public static readonly Version BODY_TRACKING_EXPECTED_VERSION = new Version(0, 9, 3);

/// <summary>Name of ONNX runtime library (DLL) which is used by <see cref="BODY_TRACKING_DLL_NAME"/>.</summary>
/// <remarks>This library is required for Body Tracking part of API (see <c>K4AdotNet.BodyTracking</c> namespace).</remarks>
public const string ONNX_RUNTIME_DLL_NAME = "onnxruntime";

/// <summary>Name of ONNX file with model of neural network used by <see cref="BODY_TRACKING_DLL_NAME"/>.</summary>
/// <remarks>This data file is required for Body Tracking part of API (see <c>K4AdotNet.BodyTracking</c> namespace).</remarks>
public const string BODY_TRACKING_DNN_MODEL_FILE_NAME = "dnn_model.onnx";
public const string BODY_TRACKING_DNN_MODEL_FILE_NAME = "dnn_model_2_0.onnx";

/// <summary>ONNX runtime depends on NVIDIA cuDNN library. This list contains all required components for cuDNN under Windows.</summary>
public static readonly IReadOnlyList<string> CUDNN_DLL_NAMES = new[]
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* See https://docs.microsoft.com/en-us/dotnet/standard/net-standard for details
* Clean API, which is close to C/C++ native API from [Azure Kinect Sensor SDK](https://docs.microsoft.com/en-us/azure/Kinect-dk/sensor-sdk-download) and [Azure Kinect Body Tracking SDK](https://docs.microsoft.com/en-us/azure/Kinect-dk/body-sdk-download).
* Plus useful helper methods, additional checks and meaningful exceptions.
* Full feature set (all API provided by native SDKs are available in this C# wrapper)
* Up-to-date with the latest versions of native SDKs
* No additional dependencies
* Except dependencies on native libraries (DLLs) from [Azure Kinect Sensor SDK](https://docs.microsoft.com/en-us/azure/Kinect-dk/sensor-sdk-download) and [Azure Kinect Body Tracking SDK](https://docs.microsoft.com/en-us/azure/Kinect-dk/body-sdk-download)
* Native libraries from [Azure Kinect Sensor SDK](https://docs.microsoft.com/en-us/azure/Kinect-dk/sensor-sdk-download) are included to repository(see `externals` directory) and [NuGet package](https://www.nuget.org/packages/K4AdotNet)
Expand All @@ -49,14 +51,14 @@
|---------------------|----------------------------------------------|----------------|---------------------------------------|--------------------------
| Sensor API | `k4a.dll`, `depthengine_2_0.dll`<sup>(1)</sup> | 1.2.0 | `externals/k4a/windows-desktop/amd64` | YES
| Record API | `k4arecord.dll` | 1.2.0 | `externals/k4a/windows-desktop/amd64` | YES
| Body Tracking API | `k4abt.dll`<sup>(2)</sup>, `dnn_model.onnx` | 0.9.2 | | no<sup>(3)</sup>
| Body Tracking API | `k4abt.dll`<sup>(2)</sup>, `dnn_model_2_0.onnx` | 0.9.3 | | no<sup>(3)</sup>

Notes:
* <sup>(1)</sup> `depthengine_2_0.dll` is required only if you are using `Transformation` or `Device` classes. All other Sensor API (types from `K4AdotNet.Sensor` namespace) depends only on `k4a.dll`.
* <sup>(2)</sup> `k4abt.dll` uses [ONNX Runtime](https://github.com/microsoft/onnxruntime) &mdash; `onnxruntime.dll`, which in turn depends on the following [NVIDIA cuDNN](https://developer.nvidia.com/cudnn) and [NVIDIA CUDA 10.0](https://developer.nvidia.com/cuda-10.0-download-archive) libraries: `cudnn64_7.dll`, `cublas64_100.dll`, `cudart64_100.dll`. Also, Visual C++ Redistributable for Visual Studio 2015 is required: `vcomp140.dll`.
* <sup>(3)</sup> The full list of libraries and data files required for Body Tracking: <br/>
`k4abt.dll` (3.7 MB), <br/>
`dnn_model.onnx` (159 MB), <br/>
`dnn_model_2_0.onnx` (159 MB), <br/>
`cudnn64_7.dll` (333 MB), <br/>
`cublas64_100.dll` (64 MB), <br/>
`cudart64_100.dll` (0.4 MB), <br/>
Expand All @@ -83,7 +85,6 @@ See https://github.com/bibigone/k4a.net/releases

* More unit and integration tests
* More samples (Recording, 3D view, Box-man, IMU...)
* Further development of sample for Unity
* Find out how to convert MJPEG -> BGRA faster (implementation in `k4a.dll` is very slow)
* Test under Linux, samples for Linux (using [Avalonia UI Framework](http://avaloniaui.net/)?)
* Some hosting for HTML documentation ([DocFX](https://dotnet.github.io/docfx/) + [github.io](https://pages.github.com/)?)
Expand Down
2 changes: 1 addition & 1 deletion externals/k4abt/REDIST.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sdk\windows-desktop\amd64\release\bin\k4abt.dll
sdk\windows-desktop\amd64\release\bin\onnxruntime.dll
sdk\windows-desktop\amd64\release\bin\dnn_model.onnx
sdk\windows-desktop\amd64\release\bin\dnn_model_2_0.onnx
tools\cublas64_100.dll
tools\cudart64_100.dll
tools\cudnn64_7.dll
Expand Down
2 changes: 1 addition & 1 deletion externals/k4abt/include/k4abt.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern "C" {
*
* \param smoothing_factor
* Set between 0 for no smoothing and 1 for full smoothing. Less smoothing will increase the responsiveness of the
* detected skeletons but will cause more positional and oriantational jitters.
* detected skeletons but will cause more positional and orientational jitters.
*
* \relates k4abt_tracker_t
*
Expand Down
2 changes: 1 addition & 1 deletion externals/k4abt/include/k4abttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ typedef struct _k4abt_body_t

/** The default tracker temporal smoothing factor
*/
#define K4ABT_DEFAULT_TRACKER_SMOOTHING_FACTOR 0.5f
#define K4ABT_DEFAULT_TRACKER_SMOOTHING_FACTOR 0.0f

/** Default configuration setting for k4abt tracker.
*
Expand Down
14 changes: 8 additions & 6 deletions externals/k4abt/include/k4abtversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
#ifndef K4ABTVERSION_H
#define K4ABTVERSION_H

#define K4ABT_VERSION_MAJOR 0
#define K4ABT_VERSION_MINOR 9
#define K4ABT_VERSION_PATCH 2
#define K4ABT_VERSION_PRERELEASE ""
#define K4ABT_VERSION_BUILD_METADATA ""
#define K4ABT_VERSION_MAJOR 0
#define K4ABT_VERSION_MINOR 9
#define K4ABT_VERSION_PATCH 3
#define K4ABT_VERSION_PRERELEASE ""
#define K4ABT_VERSION_BUILD_METADATA ""

#define K4ABT_VERSION_STR "0.9.2"
#define K4ABT_VERSION_STR "0.9.3"

#define K4ABT_DNN_MODEL_FILE "dnn_model_2_0.onnx"

#endif
2 changes: 1 addition & 1 deletion externals/k4abt/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.2
0.9.3

0 comments on commit 333fd8f

Please sign in to comment.