diff --git a/K4AdotNet.Samples.Unity/Assets/Scripts/CaptureManager.cs b/K4AdotNet.Samples.Unity/Assets/Scripts/CaptureManager.cs index 85c6888..5251c27 100644 --- a/K4AdotNet.Samples.Unity/Assets/Scripts/CaptureManager.cs +++ b/K4AdotNet.Samples.Unity/Assets/Scripts/CaptureManager.cs @@ -24,7 +24,7 @@ private void Awake() ColorResolution = ColorResolution.R720p, ColorFormat = ImageFormat.ColorBgra32, DepthMode = DepthMode.NarrowViewUnbinned, - CameraFps = FrameRate.Fifteen, + CameraFps = FrameRate.Thirty, }; _device.GetCalibration(Configuration.DepthMode, Configuration.ColorResolution, out var calibration); Calibration = calibration; diff --git a/K4AdotNet.Samples.Unity/ProjectSettings/ProjectVersion.txt b/K4AdotNet.Samples.Unity/ProjectSettings/ProjectVersion.txt index 7e64146..2146a1e 100644 --- a/K4AdotNet.Samples.Unity/ProjectSettings/ProjectVersion.txt +++ b/K4AdotNet.Samples.Unity/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.2.0f1 -m_EditorVersionWithRevision: 2019.2.0f1 (20c1667945cf) +m_EditorVersion: 2019.2.6f1 +m_EditorVersionWithRevision: 2019.2.6f1 (fe82a0e88406) diff --git a/K4AdotNet.Samples.Unity/prepare.cmd b/K4AdotNet.Samples.Unity/prepare.cmd index 16e901a..31411d2 100644 --- a/K4AdotNet.Samples.Unity/prepare.cmd +++ b/K4AdotNet.Samples.Unity/prepare.cmd @@ -5,12 +5,15 @@ rem You may run it again anytime to update binaries with changes made to K4AdotN rem Build fresh K4AdotNet binaries (requires path to msbuild.exe set by Developer Command Prompt) msbuild ..\K4AdotNet -p:Configuration=Debug -rem Copy K4AdotNet binaries to a plugin folder +rem Copy K4AdotNet binaries to "Assets\Plugins\K4AdotNet" folder xcopy ..\K4AdotNet\bin\Debug\netstandard2.0\* Assets\Plugins\K4AdotNet\ /A /Y -rem Copy K4A Sensor runtime to a plugin folder +rem Copy K4A Sensor runtime to "Assets\Plugins\K4AdotNet" folder xcopy ..\externals\k4a\windows-desktop\amd64\*.dll Assets\Plugins\K4AdotNet\ /A /Y -rem Copy K4A Body Tracking runtime to a plugin folder (assumes Body Tracking SDK installed into a standard location) -rem If installed to another location then copy k4abt.dll manually -copy /y "C:\Program Files\Azure Kinect Body Tracking SDK\sdk\windows-desktop\amd64\release\bin\k4abt.dll" Assets\Plugins\K4AdotNet\ \ No newline at end of file +rem Copy k4abt.dll from K4A Body Tracking runtime to "Assets\Plugins\K4AdotNet" folder (assumes Body Tracking SDK installed into a standard location) +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\k4abt.dll" Assets\Plugins\K4AdotNet\ + +rem If Body Tracking SDK is installed to another location or you want to have portable solution which does not require installation of Body Tracking SDK +rem then copy manually the following libraries and data files from "tools" folder of Body Tracking SDK to "Assets\Plugins\K4AdotNet" folder of this plugin: +rem k4abt.dll, dnn_model_2_0.onnx, cudnn64_7.dll, cublas64_100.dll, cudart64_100.dll, vcomp140.dll. \ No newline at end of file diff --git a/K4AdotNet.Samples.Unity/readme.md b/K4AdotNet.Samples.Unity/readme.md new file mode 100644 index 0000000..c242686 --- /dev/null +++ b/K4AdotNet.Samples.Unity/readme.md @@ -0,0 +1,41 @@ +# Unity Sample + +This sample demonstrate how to work with Sensor and Body data streams from Unity +and how to animate 3D character using body data. + +## Preparations + +Before first opening a Unity project, run `prepare.cmd` from **VS Developer Command Prompt**. +It will build **K4AdotNet** project and copy necessary binaries to Unity project folders. +You may run the script anytime later to update binaries with changes made to **K4AdotNet** library. + +The script assumes that **Azure Kinect Body Tracking SDK** is installed into default location under Program Files. +If it doesn't take place or you want to have portable solution which doesn't depend on presence of Body Tracking SDK on local machine +then copy the following files from `tools` folder of Body Tracking SDK to `Assets\Plugins\K4AdotNet` folder of this plugin: +* `k4abt.dll`, +* `dnn_model_2_0.onnx`, +* `cudnn64_7.dll`, +* `cublas64_100.dll`, +* `cudart64_100.dll`, +* `vcomp140.dll`. + +## Dependencies + +This plugin depends on the following managed and native libraries and data files: +* **K4AdotNet** managed library (see `..\K4AdotNet\bin\Debug\netstandard2.0` or ``..\K4AdotNet\bin\Release\netstandard2.0`` folder): + * `K4AdotNet.dll` + * `K4AdotNet.deps.json` +* native libraries from **Azure Kinect Sensor SDK 1.3.0** (see `..\externals\k4a\windows-desktop\amd64` folder): + * `depthengine_2_0.dll` + * `k4a.dll` + * `k4arecord.dll` +* native libraries and ONNX-file from **Azure Kinect Body Tracking SDK 0.9.4** (you can download and install MSI package from [here](https://docs.microsoft.com/en-us/azure/kinect-dk/body-sdk-download) and find required files in `tools` subdirectory of installation destination directory): + * `k4abt.dll`, + * `dnn_model_2_0.onnx`, + * `cudnn64_7.dll`, + * `cublas64_100.dll`, + * `cudart64_100.dll`, + * `vcomp140.dll`. + +As a rule `prepare.cmd` does the trick, but you can copy all dependencies to `Assets\Plugins\K4AdotNet` folder of this plugin manually. + \ No newline at end of file diff --git a/K4AdotNet.Samples.Unity/readme.txt b/K4AdotNet.Samples.Unity/readme.txt deleted file mode 100644 index d54295d..0000000 --- a/K4AdotNet.Samples.Unity/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -Before first opening a Unity project, run prepare.cmd from VS Developer Command Prompt. -It will build K4AdotNet project and copy necessary binaries to Unity project folders. -You may run the script anytime later to update binaries with changes made to K4AdotNet library. - -Also the script assumes that Azure Kinect Body Tracking SDK is installed into default location under C:\Program Files. -If not copy k4abt.dll manually to Assets\Plugins\K4AdotNet. -It is commonly found in sdk\windows-desktop\amd64\release\bin in the installation directory of the SDK. \ No newline at end of file diff --git a/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingViewModel.cs b/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingViewModel.cs index 28c1738..b26b001 100644 --- a/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingViewModel.cs +++ b/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingViewModel.cs @@ -54,6 +54,8 @@ public void Dispose() depthImage.Dispose(); needUpdateBitmap.Dispose(); + + transformation.Dispose(); } } diff --git a/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingWindow.xaml.cs b/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingWindow.xaml.cs index 84e633e..8d7da83 100644 --- a/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingWindow.xaml.cs +++ b/K4AdotNet.Samples.Wpf.BackgroundRemover/ProcessingWindow.xaml.cs @@ -3,9 +3,6 @@ namespace K4AdotNet.Samples.Wpf.BackgroundRemover { - /// - /// Interaction logic for ProcessingWindow.xaml - /// public partial class ProcessingWindow : Window { public ProcessingWindow() diff --git a/K4AdotNet.Samples.Wpf.BackgroundRemover/StartWindow.xaml.cs b/K4AdotNet.Samples.Wpf.BackgroundRemover/StartWindow.xaml.cs index 29ae364..85c7bec 100644 --- a/K4AdotNet.Samples.Wpf.BackgroundRemover/StartWindow.xaml.cs +++ b/K4AdotNet.Samples.Wpf.BackgroundRemover/StartWindow.xaml.cs @@ -2,9 +2,6 @@ namespace K4AdotNet.Samples.Wpf.BackgroundRemover { - /// - /// Interaction logic for StartWindow.xaml - /// public partial class StartWindow : Window { public StartWindow() diff --git a/K4AdotNet.Samples.Wpf.BodyTracker/SkeletonVisualizer.cs b/K4AdotNet.Samples.Wpf.BodyTracker/SkeletonVisualizer.cs index f37cb80..0098c5f 100644 --- a/K4AdotNet.Samples.Wpf.BodyTracker/SkeletonVisualizer.cs +++ b/K4AdotNet.Samples.Wpf.BodyTracker/SkeletonVisualizer.cs @@ -1,7 +1,5 @@ using K4AdotNet.BodyTracking; using System; -using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Windows; using System.Windows.Media; @@ -20,8 +18,6 @@ public SkeletonVisualizer(Dispatcher dispatcher, int widthPixels, int heightPixe } this.dispatcher = dispatcher; - this.widthPixels = widthPixels; - this.heightPixels = heightPixels; this.jointToImageProjector = jointToImageProjector; // WPF stuff to draw skeleton @@ -160,8 +156,6 @@ private Brush JointConfidenceLevelToToBrush(JointConfidenceLevel confidenceLevel } private readonly Dispatcher dispatcher; - private readonly int widthPixels; - private readonly int heightPixels; private readonly Func jointToImageProjector; private readonly Rect drawingRect; private readonly DrawingGroup drawingGroup; diff --git a/K4AdotNet.Samples.Wpf.Common/ActualFpsCalculator.cs b/K4AdotNet.Samples.Wpf.Common/ActualFpsCalculator.cs index e22ac9e..421f18f 100644 --- a/K4AdotNet.Samples.Wpf.Common/ActualFpsCalculator.cs +++ b/K4AdotNet.Samples.Wpf.Common/ActualFpsCalculator.cs @@ -13,9 +13,9 @@ public sealed class ActualFpsCalculator /// Count of refresh periods that is used to calculate FPS. Default value is 5. /// Smoothing coefficient. Default value is 0f, which means no smoothing. Value must be in range [0; 1). public ActualFpsCalculator( - TimeSpan refreshPeriod = default(TimeSpan), - int periodCountForAveraging = default(int), - float smoothCoeff = default(float)) + TimeSpan refreshPeriod = default, + int periodCountForAveraging = default, + float smoothCoeff = default) { // default values if (refreshPeriod <= TimeSpan.Zero) diff --git a/K4AdotNet.Samples.Wpf.Viewer/ViewerWindow.xaml.cs b/K4AdotNet.Samples.Wpf.Viewer/ViewerWindow.xaml.cs index 85435e1..0a7fea5 100644 --- a/K4AdotNet.Samples.Wpf.Viewer/ViewerWindow.xaml.cs +++ b/K4AdotNet.Samples.Wpf.Viewer/ViewerWindow.xaml.cs @@ -1,16 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace K4AdotNet.Samples.Wpf.Viewer { diff --git a/K4AdotNet.Tests.Unit/Sensor/CaptureTests.cs b/K4AdotNet.Tests.Unit/Sensor/CaptureTests.cs index 7b4bcb6..9f5b68c 100644 --- a/K4AdotNet.Tests.Unit/Sensor/CaptureTests.cs +++ b/K4AdotNet.Tests.Unit/Sensor/CaptureTests.cs @@ -46,7 +46,7 @@ public void TestObjectDisposedException() { var capture = new Capture(); capture.Dispose(); - var tmp = capture.TemperatureC; // <- ObjectDisposedException + _ = capture.TemperatureC; // <- ObjectDisposedException } [TestMethod] diff --git a/K4AdotNet.Tests.Unit/Sensor/ImageTests.cs b/K4AdotNet.Tests.Unit/Sensor/ImageTests.cs index 0ada4e0..2119cae 100644 --- a/K4AdotNet.Tests.Unit/Sensor/ImageTests.cs +++ b/K4AdotNet.Tests.Unit/Sensor/ImageTests.cs @@ -169,7 +169,7 @@ public void TestArrayUnpinningOnDispose() // Force collecting of array GC.Collect(); - Assert.IsFalse(weakReferenceToArray.TryGetTarget(out var notUsed)); + Assert.IsFalse(weakReferenceToArray.TryGetTarget(out _)); // Nothing bad if we call dispose second time image.Dispose(); @@ -181,7 +181,7 @@ public void TestObjectDisposedException() { var image = new Image(ImageFormat.Depth16, testWidth, testHeight); image.Dispose(); - var buffer = image.Buffer; // <- ObjectDisposedException + _ = image.Buffer; // <- ObjectDisposedException } #endregion @@ -260,7 +260,7 @@ public void TestDuplicateReference() GC.Collect(); // But array is still alive because refImage keeps it - Assert.IsTrue(weakReferenceToArray.TryGetTarget(out var notUsed)); + Assert.IsTrue(weakReferenceToArray.TryGetTarget(out _)); refImage.Dispose(); } diff --git a/K4AdotNet/BodyTracking/Tracker.cs b/K4AdotNet/BodyTracking/Tracker.cs index 99d7eff..8816486 100644 --- a/K4AdotNet/BodyTracking/Tracker.cs +++ b/K4AdotNet/BodyTracking/Tracker.cs @@ -47,7 +47,7 @@ public sealed class Tracker : IDisposablePlus /// /// /// - public Tracker(ref Calibration calibration, TrackerConfiguration config = default(TrackerConfiguration)) + public Tracker(ref Calibration calibration, TrackerConfiguration config = default) { if (!calibration.DepthMode.HasDepth()) throw new ArgumentOutOfRangeException(nameof(calibration) + "." + nameof(calibration.DepthMode)); @@ -180,7 +180,7 @@ public float TemporalSmoothingFactor /// doesn't contain depth data compatible with . /// Object was disposed before this call or has been disposed during this call. /// Cannot add capture to the tracker for some unknown reason. See logs for details. - public bool TryEnqueueCapture(Capture capture, Timeout timeout = default(Timeout)) + public bool TryEnqueueCapture(Capture capture, Timeout timeout = default) { if (capture == null) throw new ArgumentNullException(nameof(capture)); @@ -252,7 +252,7 @@ public void EnqueueCapture(Capture capture) /// Object was disposed before this call or has been disposed during this call. /// Cannot get body frame for some unknown reason. See logs for details. /// - public bool TryPopResult(out BodyFrame bodyFrame, Timeout timeout = default(Timeout)) + public bool TryPopResult(out BodyFrame bodyFrame, Timeout timeout = default) { var res = NativeApi.TrackerPopResult(handle.ValueNotDisposed, out var bodyFrameHandle, timeout); if (res == NativeCallResults.WaitResult.Timeout) diff --git a/K4AdotNet/K4AdotNet.xml b/K4AdotNet/K4AdotNet.xml index 3086d0d..402b386 100644 --- a/K4AdotNet/K4AdotNet.xml +++ b/K4AdotNet/K4AdotNet.xml @@ -322,6 +322,15 @@ Left wrist joint. + + Left hand joint. + + + Tip of left hand joint. + + + Left thumb joint. + Right clavicle joint. @@ -334,6 +343,15 @@ Right wrist joint. + + Right hand joint. + + + Tip of right hand joint. + + + Right thumb joint. + Left hip joint. @@ -623,6 +641,15 @@ Left wrist joint. + + Left hand joint. + + + Tip of left hand joint. + + + Left thumb joint. + Right clavicle joint. @@ -635,6 +662,15 @@ Right wrist joint. + + Right hand joint. + + + Tip of right hand joint. + + + Right thumb joint. + Left hip joint. diff --git a/K4AdotNet/Sensor/Calibration.cs b/K4AdotNet/Sensor/Calibration.cs index 9572dd3..b682526 100644 --- a/K4AdotNet/Sensor/Calibration.cs +++ b/K4AdotNet/Sensor/Calibration.cs @@ -96,7 +96,7 @@ public static void CreateDummy(DepthMode depthMode, ColorResolution colorResolut if (depthMode == DepthMode.Off && colorResolution == ColorResolution.Off) throw new ArgumentOutOfRangeException(nameof(depthMode) + " and " + nameof(colorResolution), $"{nameof(depthMode)} and {nameof(colorResolution)} cannot be equal to Off simultaneously."); - calibration = default(Calibration); + calibration = default; // depth camera calibration.DepthMode = depthMode; diff --git a/K4AdotNet/Sensor/Device.cs b/K4AdotNet/Sensor/Device.cs index 72748dc..4867e90 100644 --- a/K4AdotNet/Sensor/Device.cs +++ b/K4AdotNet/Sensor/Device.cs @@ -66,7 +66,7 @@ public void Dispose() /// public bool IsConnected => !handle.IsDisposed - && NativeApi.DeviceGetSyncJack(handle.Value, out var notUsed1, out var notUsed2) == NativeCallResults.Result.Succeeded; + && NativeApi.DeviceGetSyncJack(handle.Value, out _, out _) == NativeCallResults.Result.Succeeded; /// Gets the device jack status for the synchronization in connectors. /// @@ -80,7 +80,7 @@ public bool IsSyncInConnected { get { - CheckResult(NativeApi.DeviceGetSyncJack(handle.ValueNotDisposed, out var syncInConnected, out var syncOutConnected)); + CheckResult(NativeApi.DeviceGetSyncJack(handle.ValueNotDisposed, out var syncInConnected, out _)); return syncInConnected; } } @@ -100,7 +100,7 @@ public bool IsSyncOutConnected { get { - CheckResult(NativeApi.DeviceGetSyncJack(handle.ValueNotDisposed, out var syncInConnected, out var syncOutConnected)); + CheckResult(NativeApi.DeviceGetSyncJack(handle.ValueNotDisposed, out _, out var syncOutConnected)); return syncOutConnected; } } @@ -191,7 +191,7 @@ public void StopImu() /// This method cannot be called for disposed object. /// Connection with Azure Kinect device has been lost. /// Camera streaming is not running or has been stopped during this call. - public bool TryGetCapture(out Capture capture, Timeout timeout = default(Timeout)) + public bool TryGetCapture(out Capture capture, Timeout timeout = default) { var res = NativeApi.DeviceGetCapture(handle.ValueNotDisposed, out var captureHandle, timeout); @@ -248,7 +248,7 @@ public Capture GetCapture() /// This method cannot be called for disposed object. /// Connection with Azure Kinect device has been lost. /// IMU streaming is not running or has been stopped during this call. - public bool TryGetImuSample(out ImuSample imuSample, Timeout timeout = default(Timeout)) + public bool TryGetImuSample(out ImuSample imuSample, Timeout timeout = default) { var res = NativeApi.DeviceGetImuSample(handle.ValueNotDisposed, out imuSample, timeout);