diff --git a/K4AdotNet.Samples.Core.Recorder/K4AdotNet.Samples.Core.Recorder.csproj b/K4AdotNet.Samples.Core.Recorder/K4AdotNet.Samples.Core.Recorder.csproj index fef43bb..f4d60f2 100644 --- a/K4AdotNet.Samples.Core.Recorder/K4AdotNet.Samples.Core.Recorder.csproj +++ b/K4AdotNet.Samples.Core.Recorder/K4AdotNet.Samples.Core.Recorder.csproj @@ -1,5 +1,7 @@ + + Exe netcoreapp3.1 diff --git a/K4AdotNet.Samples.Unity/Assets/Scripts/ApplicationController.cs b/K4AdotNet.Samples.Unity/Assets/Scripts/ApplicationController.cs index 394e5e6..99eef07 100644 --- a/K4AdotNet.Samples.Unity/Assets/Scripts/ApplicationController.cs +++ b/K4AdotNet.Samples.Unity/Assets/Scripts/ApplicationController.cs @@ -34,7 +34,10 @@ private IEnumerator Start() yield return new WaitUntil(() => skeletonProvider?.IsInitializationComplete != false); if (skeletonProvider?.IsAvailable != true) { - _errorMessage.Show("Cannot initialize Azure Kinect Body Tracking runtime"); + _errorMessage.Show( + "Cannot initialize Azure Kinect Body Tracking runtime.\n" + + "Make sure that there are the following files in Assets\\Plugins\\K4AdotNet folder:\n" + + "1. k4abt.dll\n2. dnn_model_2_0.onnx\n3. cudnn64_7.dll\n4. cublas64_100.dll\n5. cudart64_100.dll\n6. onnxruntime.dll\n7. vcomp140.dll"); yield break; } diff --git a/K4AdotNet.Samples.Unity/prepare.cmd b/K4AdotNet.Samples.Unity/prepare.cmd index 31411d2..80c841e 100644 --- a/K4AdotNet.Samples.Unity/prepare.cmd +++ b/K4AdotNet.Samples.Unity/prepare.cmd @@ -13,7 +13,13 @@ xcopy ..\externals\k4a\windows-desktop\amd64\*.dll Assets\Plugins\K4AdotNet\ /A 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\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\dnn_model_2_0.onnx" Assets\Plugins\K4AdotNet\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\cudnn64_7.dll" Assets\Plugins\K4AdotNet\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\cublas64_100.dll" Assets\Plugins\K4AdotNet\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\cudart64_100.dll" Assets\Plugins\K4AdotNet\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\onnxruntime.dll" Assets\Plugins\K4AdotNet\ +copy /y "%ProgramFiles%\Azure Kinect Body Tracking SDK\tools\vcomp140.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 +rem k4abt.dll, dnn_model_2_0.onnx, cudnn64_7.dll, cublas64_100.dll, cudart64_100.dll, onnxruntime.dll, vcomp140.dll. \ No newline at end of file diff --git a/K4AdotNet/K4AdotNet.xml b/K4AdotNet/K4AdotNet.xml index f14793d..a26ecc4 100644 --- a/K4AdotNet/K4AdotNet.xml +++ b/K4AdotNet/K4AdotNet.xml @@ -5908,12 +5908,9 @@ Format of image. Cannot be . Width of image in pixels. Must be positive. Height of image in pixels. Must be positive. - - Image stride in bytes (the number of bytes per horizontal line of the image). Must be non negative. - If set to 0, the stride will be set to the minimum size given the and . - + Image stride in bytes (the number of bytes per horizontal line of the image). Must be positive. - Don't use this method to create image with unknown/unspecified stride (like MJPEG). + Don't use this method to create image with unknown/unspecified stride (like and ). For such formats, size of image in bytes must be specified to create image: . @@ -5929,10 +5926,7 @@ Format of image. Width of image in pixels. Must be positive. Height of image in pixels. Must be positive. - - Image stride in bytes (the number of bytes per horizontal line of the image). Must be non negative. - If set to 0, the stride will be set to the minimum size given the and . - + Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. Zero value can be used for and . Size of image buffer in size. Non negative. Cannot be less than size calculated from image parameters. or is equal to or less than zero @@ -5940,6 +5934,30 @@ or is less than zero or is less than size calculated from and . + + Creates new image for specified underlying buffer with specified format and size in pixels. + Type of array elements in underlying buffer. Must be value type. + Underlying buffer for image. Cannot be . Object will pin and keep reference to this array during all lifetime. + Format of image. Must be format with known stride: . + Width of image in pixels. Must be positive. + Height of image in pixels. Must be positive. + Created image. Not . + + This version of method can be used only for with known dependency between image width in pixels and stride in bytes + and cannot be used for other formats. For details see . + For other formats use . + + points to pinned array for such images. + + + or is equal to or less than zero + or array is too small for specified image parameters. + + + Image stride in bytes cannot be automatically calculated from for specified . + + + Creates new image for specified underlying buffer with specified format and size in pixels. Type of array elements in underlying buffer. Must be value type. @@ -5947,11 +5965,7 @@ Format of image. Width of image in pixels. Must be positive. Height of image in pixels. Must be positive. - - Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. - If set to 0, the stride will be set to the minimum size given the and . - - Created image. Not . + Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. Zero value can be used for and . /// Created image. Not . points to pinned array for such images. diff --git a/K4AdotNet/Sensor/Image.cs b/K4AdotNet/Sensor/Image.cs index a935950..dd5220e 100644 --- a/K4AdotNet/Sensor/Image.cs +++ b/K4AdotNet/Sensor/Image.cs @@ -47,12 +47,9 @@ public Image(ImageFormat format, int widthPixels, int heightPixels) /// Format of image. Cannot be . /// Width of image in pixels. Must be positive. /// Height of image in pixels. Must be positive. - /// - /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be non negative. - /// If set to 0, the stride will be set to the minimum size given the and . - /// + /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be positive. /// - /// Don't use this method to create image with unknown/unspecified stride (like MJPEG). + /// Don't use this method to create image with unknown/unspecified stride (like and ). /// For such formats, size of image in bytes must be specified to create image: . /// /// @@ -70,12 +67,11 @@ public Image(ImageFormat format, int widthPixels, int heightPixels, int strideBy throw new ArgumentOutOfRangeException(nameof(heightPixels)); if (strideBytes < 0) throw new ArgumentOutOfRangeException(nameof(strideBytes)); + if (strideBytes == 0) + throw new InvalidOperationException("Zero stride is used for formats with complex structure like MJPEG. In this case size of image in bytes must be specified to create image."); if (format.HasKnownBytesPerPixel() && strideBytes < widthPixels * format.BytesPerPixel()) throw new ArgumentOutOfRangeException(nameof(strideBytes)); - if (strideBytes == 0 && (format == ImageFormat.ColorMjpg || format == ImageFormat.Custom)) - throw new InvalidOperationException($"Size of image in bytes must be specified to create {format} image."); - var res = NativeApi.ImageCreate(format, widthPixels, heightPixels, strideBytes, out var handle); if (res != NativeCallResults.Result.Succeeded || handle == null || handle.IsInvalid) throw new ArgumentException($"Cannot create image with format {format}, size {widthPixels}x{heightPixels} pixels and stride {strideBytes} bytes."); @@ -88,10 +84,7 @@ public Image(ImageFormat format, int widthPixels, int heightPixels, int strideBy /// Format of image. /// Width of image in pixels. Must be positive. /// Height of image in pixels. Must be positive. - /// - /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be non negative. - /// If set to 0, the stride will be set to the minimum size given the and . - /// + /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. Zero value can be used for and . /// Size of image buffer in size. Non negative. Cannot be less than size calculated from image parameters. /// /// or is equal to or less than zero @@ -106,7 +99,7 @@ public Image(ImageFormat format, int widthPixels, int heightPixels, int strideBy throw new ArgumentOutOfRangeException(nameof(heightPixels)); if (strideBytes < 0) throw new ArgumentOutOfRangeException(nameof(strideBytes)); - if (format.HasKnownBytesPerPixel() && strideBytes > 0 && strideBytes < widthPixels * format.BytesPerPixel()) + if (format.HasKnownBytesPerPixel() && strideBytes < widthPixels * format.BytesPerPixel()) throw new ArgumentOutOfRangeException(nameof(strideBytes)); if (sizeBytes <= 0) throw new ArgumentOutOfRangeException(nameof(sizeBytes)); @@ -130,15 +123,37 @@ public Image(ImageFormat format, int widthPixels, int heightPixels, int strideBy /// Creates new image for specified underlying buffer with specified format and size in pixels. /// Type of array elements in underlying buffer. Must be value type. /// Underlying buffer for image. Cannot be . Object will pin and keep reference to this array during all lifetime. - /// Format of image. + /// Format of image. Must be format with known stride: . /// Width of image in pixels. Must be positive. /// Height of image in pixels. Must be positive. - /// - /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. - /// If set to 0, the stride will be set to the minimum size given the and . - /// /// Created image. Not . /// + /// This version of method can be used only for with known dependency between image width in pixels and stride in bytes + /// and cannot be used for other formats. For details see . + /// For other formats use . + /// + /// points to pinned array for such images. + /// + /// + /// or is equal to or less than zero + /// or array is too small for specified image parameters. + /// + /// + /// Image stride in bytes cannot be automatically calculated from for specified . + /// + /// + public static Image CreateFromArray(T[] buffer, ImageFormat format, int widthPixels, int heightPixels) + where T : struct + => CreateFromArray(buffer, format, widthPixels, heightPixels, format.StrideBytes(widthPixels)); + + /// Creates new image for specified underlying buffer with specified format and size in pixels. + /// Type of array elements in underlying buffer. Must be value type. + /// Underlying buffer for image. Cannot be . Object will pin and keep reference to this array during all lifetime. + /// Format of image. + /// Width of image in pixels. Must be positive. + /// Height of image in pixels. Must be positive. + /// Image stride in bytes (the number of bytes per horizontal line of the image). Must be non-negative. Zero value can be used for and . /// Created image. Not . + /// /// points to pinned array for such images. /// /// @@ -146,7 +161,7 @@ public Image(ImageFormat format, int widthPixels, int heightPixels, int strideBy /// or is less than zero or is too small for specified /// or array is too small for specified image parameters. /// - public static Image CreateFromArray(T[] buffer, ImageFormat format, int widthPixels, int heightPixels, int strideBytes = 0) + public static Image CreateFromArray(T[] buffer, ImageFormat format, int widthPixels, int heightPixels, int strideBytes) where T: struct { if (buffer == null) @@ -157,7 +172,7 @@ public static Image CreateFromArray(T[] buffer, ImageFormat format, int width throw new ArgumentOutOfRangeException(nameof(heightPixels)); if (strideBytes < 0) throw new ArgumentOutOfRangeException(nameof(strideBytes)); - if (format.HasKnownBytesPerPixel() && strideBytes > 0 && strideBytes < widthPixels * format.BytesPerPixel()) + if (format.HasKnownBytesPerPixel() && strideBytes < widthPixels * format.BytesPerPixel()) throw new ArgumentOutOfRangeException(nameof(strideBytes)); var sizeBytes = buffer.Length * Marshal.SizeOf(); if (strideBytes > 0 && sizeBytes < format.ImageSizeBytes(strideBytes, heightPixels)) diff --git a/Product.props b/Product.props index 9186039..6a57114 100644 --- a/Product.props +++ b/Product.props @@ -1,7 +1,7 @@ - 1.3.5 - 1.3.5.0 + 1.4.0 + 1.4.0.0 See https://github.com/bibigone/k4a.net/releases bibigone,baSSiLL diff --git a/ProductInfo.cs b/ProductInfo.cs index 4249892..20f9c91 100644 --- a/ProductInfo.cs +++ b/ProductInfo.cs @@ -7,5 +7,5 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.3.5.0")] -[assembly: AssemblyFileVersion("1.3.5.0")] +[assembly: AssemblyVersion("1.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")]