From 29dde32240443a8437592b568d70155a740059d6 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Wed, 16 Oct 2019 17:27:20 +0300 Subject: [PATCH] Switching to version 0.9.4 of Body Tracking SDK. New joints for hands, confidence level for joints, CPU only mode (very slow!) --- .../ProcessingParameters.cs | 28 ++++++++++++++++ .../Processor.cs | 4 ++- .../Program.cs | 8 +++++ .../BackgroundTrackingLoop.cs | 4 +-- .../MainModel.cs | 11 +++++-- .../MainWindow.xaml | 16 ++++++---- .../SkeletonVisualizer.cs | 26 +++++++++++++-- .../TrackerModel.cs | 4 +-- K4AdotNet/BodyTracking/Joint.cs | 8 +++-- .../BodyTracking/JointConfidenceLevel.cs | 28 ++++++++++++++++ K4AdotNet/BodyTracking/JointType.cs | 24 ++++++++++++++ K4AdotNet/BodyTracking/JointTypes.cs | 30 +++++++++++++++++ K4AdotNet/BodyTracking/Skeleton.cs | 30 +++++++++++++++++ .../BodyTracking/TrackerConfiguration.cs | 16 ++++++++-- K4AdotNet/K4AdotNet.xml | 25 +++++++++++++++ K4AdotNet/Sdk.cs | 8 ++--- README.md | 6 ++-- externals/k4abt/include/k4abttypes.h | 32 ++++++++++++++++++- externals/k4abt/include/k4abtversion.h | 4 +-- 19 files changed, 281 insertions(+), 31 deletions(-) create mode 100644 K4AdotNet/BodyTracking/JointConfidenceLevel.cs diff --git a/K4AdotNet.Samples.Core.BodyTrackingSpeed/ProcessingParameters.cs b/K4AdotNet.Samples.Core.BodyTrackingSpeed/ProcessingParameters.cs index 39cb061..15a34aa 100644 --- a/K4AdotNet.Samples.Core.BodyTrackingSpeed/ProcessingParameters.cs +++ b/K4AdotNet.Samples.Core.BodyTrackingSpeed/ProcessingParameters.cs @@ -8,6 +8,7 @@ internal sealed class ProcessingParameters public const string MKV_FILE_EXTENSION = ".mkv"; public static readonly string MkvPathDescription = "Path to MKV file"; + public static readonly string CpuOnlyModeDescription = "CPU/GPU mode (C - use only CPU, G - use GPU, default - G)"; public static readonly string ImplementationDescription = "Optional implementation type (S - single thread, P - pop in background, E - enqueue in background, default - S)"; public static readonly string StartTimeDescription = "Optional start time of video interval in seconds (default - beginning of recording)"; public static readonly string EndTimeDescription = "Optional end time of video interval in seconds (default - end of recording)"; @@ -26,6 +27,7 @@ public static bool IsValueLikeToMkvFilePath(string value) } public string MkvPath { get; private set; } + public bool CpuOnlyMode { get; private set; } public ProcessingImplementation Implementation { get; private set; } public TimeSpan? StartTime { get; private set; } public TimeSpan? EndTime { get; private set; } @@ -68,6 +70,32 @@ public bool TrySetMkvPath(string value, out string message) return true; } + public bool TrySetCpuOnlyMode(string value, out string message) + { + if (string.IsNullOrWhiteSpace(value)) + { + CpuOnlyMode = false; + message = null; + return true; + } + + value = value.Trim().ToLowerInvariant(); + switch (value) + { + case "c": + CpuOnlyMode = true; + message = null; + return true; + case "g": + CpuOnlyMode = false; + message = null; + return true; + } + + message = $"Invalid value. Expected 'C' or 'G'."; + return false; + } + public bool TrySetImplementation(string value, out string message) { if (string.IsNullOrWhiteSpace(value)) diff --git a/K4AdotNet.Samples.Core.BodyTrackingSpeed/Processor.cs b/K4AdotNet.Samples.Core.BodyTrackingSpeed/Processor.cs index ac941a4..052a19b 100644 --- a/K4AdotNet.Samples.Core.BodyTrackingSpeed/Processor.cs +++ b/K4AdotNet.Samples.Core.BodyTrackingSpeed/Processor.cs @@ -30,7 +30,9 @@ protected Processor(ProcessingParameters processingParameters) playback.GetCalibration(out calibration); if (processingParameters.StartTime.HasValue) Seek(processingParameters.StartTime.Value); - tracker = new BodyTracking.Tracker(ref calibration); + var config = BodyTracking.TrackerConfiguration.Default; + config.CpuOnlyMode = processingParameters.CpuOnlyMode; + tracker = new BodyTracking.Tracker(ref calibration, config); } public virtual void Dispose() diff --git a/K4AdotNet.Samples.Core.BodyTrackingSpeed/Program.cs b/K4AdotNet.Samples.Core.BodyTrackingSpeed/Program.cs index 385f625..3c9bbd8 100644 --- a/K4AdotNet.Samples.Core.BodyTrackingSpeed/Program.cs +++ b/K4AdotNet.Samples.Core.BodyTrackingSpeed/Program.cs @@ -62,6 +62,8 @@ private static ProcessingParameters AskProcessingParameters() var parameters = new ProcessingParameters(); if (!AskParameter(ProcessingParameters.MkvPathDescription, parameters.TrySetMkvPath)) return null; + if (!AskParameter(ProcessingParameters.CpuOnlyModeDescription, parameters.TrySetCpuOnlyMode)) + return null; if (!AskParameter(ProcessingParameters.ImplementationDescription, parameters.TrySetImplementation)) return null; if (!AskParameter(ProcessingParameters.StartTimeDescription, parameters.TrySetStartTime)) @@ -100,6 +102,11 @@ private static ProcessingParameters ParseCommandLineArguments(string[] args) var arg = args[i].Trim(); switch (arg.ToLowerInvariant()) { + case "-m": + case "--mode": + if (!ParseArgument(args, ref i, parameters.TrySetCpuOnlyMode)) + return null; + break; case "-i": case "--implementation": if (!ParseArgument(args, ref i, parameters.TrySetImplementation)) @@ -168,6 +175,7 @@ private static void PrintHowToUse() Console.WriteLine("where: "); Console.WriteLine(" - " + ProcessingParameters.MkvPathDescription); Console.WriteLine(" options:"); + Console.WriteLine(" -m, --mode c|g\t\t" + ProcessingParameters.StartTimeDescription); Console.WriteLine(" -i, --implementation s|p|e\t\t" + ProcessingParameters.StartTimeDescription); Console.WriteLine(" -s, --startTime