mirror of
https://github.com/cosyneco/MediaPipe.NET.git
synced 2025-08-24 16:52:08 +08:00
Replace slow Marshal
operations with unsafe
(#13)
* Remove this bool marshal
* Literally remove all bool marshals
* Remove CharSet.Unicode warning
* Remove most FunctionPtr marshals
* Remove `[return: MarshalAs(...)]`
* Replace all `IntPtr`s with `void*`s
* Replace all `void*.Zero`s with `null`s
* Make native method classes unsafe
* U N S A F E
* Replace `PtrToStructure` with pointer arithmetic
* Run `dotnet format`
* Temp ugly Activator fix
* Remove `.ToPointer()`
* Use `byte` to return a `bool`
* Backwards compatibility with `Activator`
Yeah that sucks :(
* Replace `Marshal.Copy` by pointer arithmetic
* Replace `PtrToStringAnsi()` with `new string()`
* Remove unnecessary usings
* Explicitly type string pointers as `sbyte*`
* It actually doesn't hang?
* `MediaPipeException` -> `MediapipeException`
* Simplify `for` loops
* Remove unnecessary `float*` cast
* Some more explicit types for `ImageFrame`
* Remove unnecessary cast
* Looks like we forgor a `using` 💀
* Create `SafeArrayCopy` helper method
* Document `SafeArrayCopy`
This commit is contained in:
@ -17,9 +17,7 @@ namespace Mediapipe.Net.Examples.FaceMesh
|
||||
public static class Program
|
||||
{
|
||||
private static Camera? camera;
|
||||
|
||||
private static FrameConverter? converter;
|
||||
|
||||
private static FaceMeshCpuCalculator? calculator;
|
||||
|
||||
public static void Main(string[] args)
|
||||
@ -76,11 +74,11 @@ namespace Mediapipe.Net.Examples.FaceMesh
|
||||
ImageFrame imgframe;
|
||||
fixed (byte* rawDataPtr = cFrame.RawData)
|
||||
{
|
||||
imgframe = new ImageFrame(ImageFormat.Srgba, cFrame.Width, cFrame.Height, cFrame.WidthStep,
|
||||
rawDataPtr);
|
||||
imgframe = new ImageFrame(ImageFormat.Srgba,
|
||||
cFrame.Width, cFrame.Height, cFrame.WidthStep, rawDataPtr);
|
||||
}
|
||||
|
||||
ImageFrame img = calculator.Send(imgframe);
|
||||
using ImageFrame img = calculator.Send(imgframe);
|
||||
imgframe.Dispose();
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ namespace Mediapipe.Net.Examples.FaceMeshGpu
|
||||
imgframe = new ImageFrame(ImageFormat.Srgba,
|
||||
cFrame.Width, cFrame.Height, cFrame.WidthStep, rawDataPtr);
|
||||
}
|
||||
|
||||
using ImageFrame img = calculator.Send(imgframe);
|
||||
imgframe.Dispose();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace Mediapipe.Net.Examples.OsuFrameworkVisualTests
|
||||
using ImageFrame outImgFrame = calculator.Send(imgFrame);
|
||||
imgFrame.Dispose();
|
||||
|
||||
var span = new ReadOnlySpan<byte>((byte*)outImgFrame.MutablePixelData, outImgFrame.Height * outImgFrame.WidthStep);
|
||||
var span = new ReadOnlySpan<byte>(outImgFrame.MutablePixelData, outImgFrame.Height * outImgFrame.WidthStep);
|
||||
var pixelData = SixLabors.ImageSharp.Image.LoadPixelData<Rgba32>(span, cFrame.Width, cFrame.Height);
|
||||
|
||||
texture ??= new Texture(cFrame.Width, cFrame.Height);
|
||||
|
@ -31,7 +31,10 @@ namespace Mediapipe.Net.Tests.Framework.Format
|
||||
Assert.True(imageFrame.IsEmpty);
|
||||
Assert.False(imageFrame.IsContiguous);
|
||||
Assert.False(imageFrame.IsAligned(16));
|
||||
Assert.AreEqual(imageFrame.MutablePixelData, IntPtr.Zero);
|
||||
unsafe
|
||||
{
|
||||
Assert.True(imageFrame.MutablePixelData == null);
|
||||
}
|
||||
#pragma warning restore IDE0058
|
||||
}
|
||||
|
||||
@ -51,7 +54,10 @@ namespace Mediapipe.Net.Tests.Framework.Format
|
||||
Assert.False(imageFrame.IsEmpty);
|
||||
Assert.True(imageFrame.IsContiguous);
|
||||
Assert.True(imageFrame.IsAligned(16));
|
||||
Assert.AreNotEqual(imageFrame.MutablePixelData, IntPtr.Zero);
|
||||
unsafe
|
||||
{
|
||||
Assert.True(imageFrame.MutablePixelData != null);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -85,7 +91,7 @@ namespace Mediapipe.Net.Tests.Framework.Format
|
||||
}
|
||||
|
||||
[Test, SignalAbort]
|
||||
public void Ctor_ShouldThrowMediaPipeException_When_CalledWithInvalidArgument()
|
||||
public void Ctor_ShouldThrowMediapipeException_When_CalledWithInvalidArgument()
|
||||
{
|
||||
#pragma warning disable IDE0058
|
||||
Assert.Throws<MediapipeException>(() => { new ImageFrame(ImageFormat.Sbgra, 640, 480, 0); });
|
||||
|
@ -81,7 +81,7 @@ namespace Mediapipe.Net.Tests.Framework.Packet
|
||||
|
||||
#region Get
|
||||
[Test, SignalAbort]
|
||||
public void Get_ShouldThrowMediaPipeException_When_DataIsEmpty()
|
||||
public void Get_ShouldThrowMediapipeException_When_DataIsEmpty()
|
||||
{
|
||||
using var packet = new ImageFramePacket();
|
||||
#pragma warning disable IDE0058
|
||||
|
@ -18,7 +18,10 @@ namespace Mediapipe.Net.Tests.Gpu
|
||||
public void Ctor_ShouldInstantiateGlCalculatorHelper()
|
||||
{
|
||||
using var glCalculatorHelper = new GlCalculatorHelper();
|
||||
Assert.AreNotEqual(glCalculatorHelper.MpPtr, IntPtr.Zero);
|
||||
unsafe
|
||||
{
|
||||
Assert.True(glCalculatorHelper.MpPtr != null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -110,7 +113,6 @@ namespace Mediapipe.Net.Tests.Gpu
|
||||
}
|
||||
|
||||
[Test, GpuOnly]
|
||||
[Ignore("Skip because a thread hangs")]
|
||||
public void CreateSourceTexture_ShouldFail_When_ImageFrameFormatIsInvalid()
|
||||
{
|
||||
using var glCalculatorHelper = new GlCalculatorHelper();
|
||||
@ -172,12 +174,15 @@ namespace Mediapipe.Net.Tests.Gpu
|
||||
|
||||
using var glContext = glCalculatorHelper.GetGlContext();
|
||||
|
||||
if (OperatingSystem.IsLinux() || OperatingSystem.IsAndroid())
|
||||
Assert.AreNotEqual(glContext.EglContext, IntPtr.Zero);
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
Assert.AreNotEqual(glContext.NsglContext, IntPtr.Zero);
|
||||
else if (OperatingSystem.IsIOS())
|
||||
Assert.AreNotEqual(glContext.EaglContext, IntPtr.Zero);
|
||||
unsafe
|
||||
{
|
||||
if (OperatingSystem.IsLinux() || OperatingSystem.IsAndroid())
|
||||
Assert.True(glContext.EglContext != null);
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
Assert.True(glContext.NsglContext != null);
|
||||
else if (OperatingSystem.IsIOS())
|
||||
Assert.True(glContext.EaglContext != null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -48,25 +48,25 @@ namespace Mediapipe.Net.Tests.Gpu
|
||||
|
||||
#region Properties
|
||||
[Test, GpuOnly]
|
||||
public void ShouldReturnProperties()
|
||||
public unsafe void ShouldReturnProperties()
|
||||
{
|
||||
using var glContext = getGlContext();
|
||||
if (OperatingSystem.IsLinux() || OperatingSystem.IsAndroid())
|
||||
{
|
||||
Assert.AreNotEqual(glContext.EglDisplay, IntPtr.Zero);
|
||||
Assert.AreNotEqual(glContext.EglConfig, IntPtr.Zero);
|
||||
Assert.AreNotEqual(glContext.EglContext, IntPtr.Zero);
|
||||
Assert.True(glContext.EglDisplay != null);
|
||||
Assert.True(glContext.EglConfig != null);
|
||||
Assert.True(glContext.EglContext != null);
|
||||
Assert.AreEqual(glContext.GlMajorVersion, 3);
|
||||
Assert.AreEqual(glContext.GlMinorVersion, 2);
|
||||
Assert.AreEqual(glContext.GlFinishCount, 0);
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
Assert.AreNotEqual(glContext.NsglContext, IntPtr.Zero);
|
||||
Assert.True(glContext.NsglContext != null);
|
||||
}
|
||||
else if (OperatingSystem.IsIOS())
|
||||
{
|
||||
Assert.AreNotEqual(glContext.EaglContext, IntPtr.Zero);
|
||||
Assert.True(glContext.EaglContext != null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -63,7 +63,10 @@ namespace Mediapipe.Net.Calculators
|
||||
outFrame = new ImageFrame(outBuffer.Format.ImageFormatFor(), outBuffer.Width, outBuffer.Height, ImageFrame.GlDefaultAlignmentBoundary);
|
||||
gpuHelper.BindFramebuffer(texture);
|
||||
GlTextureInfo info = outBuffer.Format.GlTextureInfoFor(0);
|
||||
Gl.ReadPixels(0, 0, texture.Width, texture.Height, info.GlFormat, info.GlType, outFrame.MutablePixelData);
|
||||
unsafe
|
||||
{
|
||||
Gl.ReadPixels(0, 0, texture.Width, texture.Height, info.GlFormat, info.GlType, outFrame.MutablePixelData);
|
||||
}
|
||||
Gl.Flush();
|
||||
texture.Release();
|
||||
|
||||
|
@ -6,9 +6,9 @@ using System;
|
||||
|
||||
namespace Mediapipe.Net.Core
|
||||
{
|
||||
public interface IMpResourceHandle : IDisposable
|
||||
public unsafe interface IMpResourceHandle : IDisposable
|
||||
{
|
||||
IntPtr MpPtr { get; }
|
||||
void* MpPtr { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Relinquish the ownership, and release the resource it owns if necessary.
|
||||
|
@ -3,25 +3,24 @@
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Native;
|
||||
using static Mediapipe.Net.Native.MpReturnCodeExtension;
|
||||
|
||||
namespace Mediapipe.Net.Core
|
||||
{
|
||||
public abstract class MpResourceHandle : Disposable, IMpResourceHandle
|
||||
public unsafe abstract class MpResourceHandle : Disposable, IMpResourceHandle
|
||||
{
|
||||
protected IntPtr Ptr;
|
||||
protected void* Ptr;
|
||||
|
||||
protected MpResourceHandle(bool isOwner = true) : this(IntPtr.Zero, isOwner) { }
|
||||
protected MpResourceHandle(bool isOwner = true) : this(null, isOwner) { }
|
||||
|
||||
protected MpResourceHandle(IntPtr ptr, bool isOwner = true) : base(isOwner)
|
||||
protected MpResourceHandle(void* ptr, bool isOwner = true) : base(isOwner)
|
||||
{
|
||||
Ptr = ptr;
|
||||
}
|
||||
|
||||
#region IMpResourceHandle
|
||||
public IntPtr MpPtr
|
||||
public void* MpPtr
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -38,7 +37,7 @@ namespace Mediapipe.Net.Core
|
||||
TransferOwnership();
|
||||
}
|
||||
|
||||
public bool OwnsResource => IsOwner && Ptr != IntPtr.Zero;
|
||||
public bool OwnsResource => IsOwner && Ptr != null;
|
||||
#endregion
|
||||
|
||||
protected override void DisposeUnmanaged()
|
||||
@ -54,7 +53,7 @@ namespace Mediapipe.Net.Core
|
||||
/// Forgets the pointer address.
|
||||
/// After calling this method, <see ref="OwnsResource" /> will return false.
|
||||
/// </summary>
|
||||
protected void ReleaseMpPtr() => Ptr = IntPtr.Zero;
|
||||
protected void ReleaseMpPtr() => Ptr = null;
|
||||
|
||||
/// <summary>
|
||||
/// Release the memory (call `delete` or `delete[]`) whether or not it owns it.
|
||||
@ -62,13 +61,13 @@ namespace Mediapipe.Net.Core
|
||||
/// <remarks>In most cases, this method should not be called directly.</remarks>
|
||||
protected abstract void DeleteMpPtr();
|
||||
|
||||
protected delegate MpReturnCode StringOutFunc(IntPtr ptr, out IntPtr strPtr);
|
||||
protected delegate MpReturnCode StringOutFunc(void* ptr, out sbyte* strPtr);
|
||||
protected string? MarshalStringFromNative(StringOutFunc func)
|
||||
{
|
||||
func(MpPtr, out IntPtr strPtr).Assert();
|
||||
func(MpPtr, out sbyte* strPtr).Assert();
|
||||
GC.KeepAlive(this);
|
||||
|
||||
string? str = Marshal.PtrToStringAnsi(strPtr);
|
||||
string? str = new string(strPtr);
|
||||
UnsafeNativeMethods.delete_array__PKc(strPtr);
|
||||
|
||||
return str;
|
||||
|
@ -2,16 +2,14 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mediapipe.Net.Core
|
||||
{
|
||||
public abstract class SharedPtrHandle : MpResourceHandle
|
||||
public unsafe abstract class SharedPtrHandle : MpResourceHandle
|
||||
{
|
||||
protected SharedPtrHandle(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
protected SharedPtrHandle(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
/// <returns>The owning pointer</returns>
|
||||
public abstract IntPtr Get();
|
||||
public abstract void* Get();
|
||||
|
||||
/// <summary>Release the owning pointer</summary>
|
||||
public abstract void Reset();
|
||||
|
@ -2,18 +2,16 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mediapipe.Net.Core
|
||||
{
|
||||
public abstract class UniquePtrHandle : MpResourceHandle
|
||||
public unsafe abstract class UniquePtrHandle : MpResourceHandle
|
||||
{
|
||||
protected UniquePtrHandle(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
protected UniquePtrHandle(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
/// <returns>The owning pointer</returns>
|
||||
public abstract IntPtr Get();
|
||||
public abstract void* Get();
|
||||
|
||||
/// <summary>Release the owning pointer</summary>
|
||||
public abstract IntPtr Release();
|
||||
public abstract void* Release();
|
||||
}
|
||||
}
|
||||
|
9
Mediapipe.Net/External/SerializedProto.cs
vendored
9
Mediapipe.Net/External/SerializedProto.cs
vendored
@ -2,17 +2,17 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Google.Protobuf;
|
||||
using Mediapipe.Net.Native;
|
||||
using Mediapipe.Net.Util;
|
||||
|
||||
namespace Mediapipe.Net.External
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SerializedProto
|
||||
internal unsafe struct SerializedProto
|
||||
{
|
||||
public IntPtr StrPtr;
|
||||
public sbyte* StrPtr;
|
||||
public int Length;
|
||||
|
||||
// TODO: That Dispose() method is looking very sus...
|
||||
@ -21,8 +21,7 @@ namespace Mediapipe.Net.External
|
||||
|
||||
public T Deserialize<T>(MessageParser<T> parser) where T : IMessage<T>
|
||||
{
|
||||
byte[] bytes = new byte[Length];
|
||||
Marshal.Copy(StrPtr, bytes, 0, bytes.Length);
|
||||
byte[] bytes = UnsafeUtil.SafeArrayCopy((byte*)StrPtr, Length);
|
||||
return parser.ParseFrom(bytes);
|
||||
}
|
||||
}
|
||||
|
18
Mediapipe.Net/External/SerializedProtoVector.cs
vendored
18
Mediapipe.Net/External/SerializedProtoVector.cs
vendored
@ -2,7 +2,6 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Google.Protobuf;
|
||||
@ -11,9 +10,9 @@ using Mediapipe.Net.Native;
|
||||
namespace Mediapipe.Net.External
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SerializedProtoVector
|
||||
internal unsafe struct SerializedProtoVector
|
||||
{
|
||||
public IntPtr Data;
|
||||
public SerializedProto* Data;
|
||||
public int Size;
|
||||
|
||||
// TODO: This is looking just as sus as SerializedProto.Dispose().
|
||||
@ -23,17 +22,8 @@ namespace Mediapipe.Net.External
|
||||
public List<T> Deserialize<T>(MessageParser<T> parser) where T : IMessage<T>
|
||||
{
|
||||
var protos = new List<T>(Size);
|
||||
|
||||
unsafe
|
||||
{
|
||||
var protoPtr = (SerializedProto*)Data;
|
||||
|
||||
for (var i = 0; i < Size; i++)
|
||||
{
|
||||
var serializedProto = Marshal.PtrToStructure<SerializedProto>((IntPtr)protoPtr++);
|
||||
protos.Add(serializedProto.Deserialize(parser));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < Size; i++)
|
||||
protos.Add(Data[i].Deserialize(parser));
|
||||
|
||||
return protos;
|
||||
}
|
||||
|
6
Mediapipe.Net/External/StdString.cs
vendored
6
Mediapipe.Net/External/StdString.cs
vendored
@ -8,9 +8,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.External
|
||||
{
|
||||
public class StdString : MpResourceHandle
|
||||
public unsafe class StdString : MpResourceHandle
|
||||
{
|
||||
public StdString(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public StdString(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
public StdString(byte[] bytes) : base()
|
||||
{
|
||||
@ -18,7 +18,7 @@ namespace Mediapipe.Net.External
|
||||
Ptr = ptr;
|
||||
}
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.std_string__delete(Ptr);
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.std_string__delete((sbyte*)Ptr);
|
||||
|
||||
public void Swap(StdString str)
|
||||
{
|
||||
|
@ -15,9 +15,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework
|
||||
{
|
||||
public class CalculatorGraph : MpResourceHandle
|
||||
public unsafe class CalculatorGraph : MpResourceHandle
|
||||
{
|
||||
public delegate IntPtr NativePacketCallback(IntPtr graphPtr, IntPtr packetPtr);
|
||||
public delegate void* NativePacketCallback(void* graphPtr, void* packetPtr);
|
||||
public delegate Status PacketCallback<TPacket, TValue>(TPacket? packet) where TPacket : Packet<TValue>;
|
||||
|
||||
public CalculatorGraph() : base()
|
||||
@ -87,7 +87,7 @@ namespace Mediapipe.Net.Framework
|
||||
Status status;
|
||||
try
|
||||
{
|
||||
var packet = (TPacket?)Activator.CreateInstance(typeof(TPacket), packetPtr, false);
|
||||
var packet = (TPacket?)Activator.CreateInstance(typeof(TPacket), (IntPtr)packetPtr, false);
|
||||
status = packetCallback(packet);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -150,7 +150,7 @@ namespace Mediapipe.Net.Framework
|
||||
return new Status(statusPtr);
|
||||
}
|
||||
|
||||
public bool HasError() => SafeNativeMethods.mp_CalculatorGraph__HasError(MpPtr);
|
||||
public bool HasError() => SafeNativeMethods.mp_CalculatorGraph__HasError(MpPtr) > 0;
|
||||
|
||||
public Status AddPacketToInputStream<T>(string streamName, Packet<T> packet)
|
||||
{
|
||||
@ -191,11 +191,11 @@ namespace Mediapipe.Net.Framework
|
||||
GC.KeepAlive(this);
|
||||
}
|
||||
|
||||
public bool GraphInputStreamsClosed() => SafeNativeMethods.mp_CalculatorGraph__GraphInputStreamsClosed(MpPtr);
|
||||
public bool GraphInputStreamsClosed() => SafeNativeMethods.mp_CalculatorGraph__GraphInputStreamsClosed(MpPtr) > 0;
|
||||
|
||||
public bool IsNodeThrottled(int nodeId) => SafeNativeMethods.mp_CalculatorGraph__IsNodeThrottled__i(MpPtr, nodeId);
|
||||
public bool IsNodeThrottled(int nodeId) => SafeNativeMethods.mp_CalculatorGraph__IsNodeThrottled__i(MpPtr, nodeId) > 0;
|
||||
|
||||
public bool UnthrottleSources() => SafeNativeMethods.mp_CalculatorGraph__UnthrottleSources(MpPtr);
|
||||
public bool UnthrottleSources() => SafeNativeMethods.mp_CalculatorGraph__UnthrottleSources(MpPtr) > 0;
|
||||
|
||||
public GpuResources GetGpuResources()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Mediapipe.Net.Framework
|
||||
{
|
||||
public static CalculatorGraphConfig ParseFromTextFormat(this MessageParser<CalculatorGraphConfig> _, string configText)
|
||||
{
|
||||
if (UnsafeNativeMethods.mp_api__ConvertFromCalculatorGraphConfigTextFormat(configText, out var serializedProto))
|
||||
if (UnsafeNativeMethods.mp_api__ConvertFromCalculatorGraphConfigTextFormat(configText, out var serializedProto) > 0)
|
||||
{
|
||||
var config = serializedProto.Deserialize(CalculatorGraphConfig.Parser);
|
||||
serializedProto.Dispose();
|
||||
|
@ -8,12 +8,12 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Format
|
||||
{
|
||||
public class ImageFrame : MpResourceHandle
|
||||
public unsafe class ImageFrame : MpResourceHandle
|
||||
{
|
||||
public static readonly uint DefaultAlignmentBoundary = 16;
|
||||
public static readonly uint GlDefaultAlignmentBoundary = 4;
|
||||
|
||||
public delegate void Deleter(IntPtr ptr);
|
||||
public delegate void Deleter(void* ptr);
|
||||
|
||||
public ImageFrame() : base()
|
||||
{
|
||||
@ -21,7 +21,7 @@ namespace Mediapipe.Net.Framework.Format
|
||||
Ptr = ptr;
|
||||
}
|
||||
|
||||
public ImageFrame(IntPtr imageFramePtr, bool isOwner = true) : base(imageFramePtr, isOwner) { }
|
||||
public ImageFrame(void* imageFramePtr, bool isOwner = true) : base(imageFramePtr, isOwner) { }
|
||||
|
||||
public ImageFrame(ImageFormat format, int width, int height) : this(format, width, height, DefaultAlignmentBoundary) { }
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Mediapipe.Net.Framework.Format
|
||||
{
|
||||
UnsafeNativeMethods.mp_ImageFrame__ui_i_i_i_Pui8_PF(
|
||||
format, width, height, widthStep,
|
||||
(IntPtr)pixelData,
|
||||
pixelData,
|
||||
releasePixelData,
|
||||
out var ptr).Assert();
|
||||
Ptr = ptr;
|
||||
@ -52,14 +52,14 @@ namespace Mediapipe.Net.Framework.Format
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_ImageFrame__delete(Ptr);
|
||||
|
||||
// [AOT.MonoPInvokeCallback(typeof(Deleter))] (?)
|
||||
private static void releasePixelData(IntPtr ptr)
|
||||
private static void releasePixelData(void* ptr)
|
||||
{
|
||||
// Do nothing (pixelData is moved)
|
||||
}
|
||||
|
||||
public bool IsEmpty => SafeNativeMethods.mp_ImageFrame__IsEmpty(MpPtr);
|
||||
public bool IsEmpty => SafeNativeMethods.mp_ImageFrame__IsEmpty(MpPtr) > 0;
|
||||
|
||||
public bool IsContiguous => SafeNativeMethods.mp_ImageFrame__IsContiguous(MpPtr);
|
||||
public bool IsContiguous => SafeNativeMethods.mp_ImageFrame__IsContiguous(MpPtr) > 0;
|
||||
|
||||
public bool IsAligned(uint alignmentBoundary)
|
||||
{
|
||||
@ -110,7 +110,7 @@ namespace Mediapipe.Net.Framework.Format
|
||||
|
||||
public int WidthStep => SafeNativeMethods.mp_ImageFrame__WidthStep(MpPtr);
|
||||
|
||||
public IntPtr MutablePixelData => SafeNativeMethods.mp_ImageFrame__MutablePixelData(MpPtr);
|
||||
public byte* MutablePixelData => SafeNativeMethods.mp_ImageFrame__MutablePixelData(MpPtr);
|
||||
|
||||
public int PixelDataSize => SafeNativeMethods.mp_ImageFrame__PixelDataSize(MpPtr);
|
||||
|
||||
@ -190,9 +190,11 @@ namespace Mediapipe.Net.Framework.Format
|
||||
public byte[] GetChannel(int channelNumber, bool flipVertically)
|
||||
=> GetChannel(channelNumber, flipVertically, new byte[Width * Height]);
|
||||
|
||||
private delegate MpReturnCode CopyToBufferHandler(IntPtr ptr, IntPtr buffer, int bufferSize);
|
||||
private delegate MpReturnCode CopyToBufferHandler<T>(void* ptr, T* buffer, int bufferSize)
|
||||
where T : unmanaged;
|
||||
|
||||
private T[] copyToBuffer<T>(CopyToBufferHandler handler, int bufferSize) where T : unmanaged
|
||||
private T[] copyToBuffer<T>(CopyToBufferHandler<T> handler, int bufferSize)
|
||||
where T : unmanaged
|
||||
{
|
||||
var buffer = new T[bufferSize];
|
||||
|
||||
@ -200,7 +202,7 @@ namespace Mediapipe.Net.Framework.Format
|
||||
{
|
||||
fixed (T* bufferPtr = buffer)
|
||||
{
|
||||
handler(MpPtr, (IntPtr)bufferPtr, bufferSize).Assert();
|
||||
handler(MpPtr, bufferPtr, bufferSize).Assert();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +227,7 @@ namespace Mediapipe.Net.Framework.Format
|
||||
/// In the source array, pixels are laid out left to right, top to bottom,
|
||||
/// but in the returned array, left to right, top to bottom.
|
||||
/// </remarks>
|
||||
private static void readChannel(IntPtr ptr, int channelNumber, int channelCount, int width, int height, int widthStep, bool flipVertically, byte[] colors)
|
||||
private static void readChannel(byte* ptr, int channelNumber, int channelCount, int width, int height, int widthStep, bool flipVertically, byte[] colors)
|
||||
{
|
||||
if (colors.Length != width * height)
|
||||
throw new ArgumentException("colors length is invalid");
|
||||
@ -235,16 +237,16 @@ namespace Mediapipe.Net.Framework.Format
|
||||
{
|
||||
fixed (byte* dest = colors)
|
||||
{
|
||||
var pSrc = (byte*)ptr.ToPointer();
|
||||
var pSrc = ptr;
|
||||
pSrc += channelNumber;
|
||||
|
||||
if (flipVertically)
|
||||
{
|
||||
var pDest = dest + colors.Length - 1;
|
||||
|
||||
for (var i = 0; i < height; i++)
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
for (var j = 0; j < width; j++)
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
*pDest-- = *pSrc;
|
||||
pSrc += channelCount;
|
||||
@ -256,9 +258,9 @@ namespace Mediapipe.Net.Framework.Format
|
||||
{
|
||||
var pDest = dest + width * (height - 1);
|
||||
|
||||
for (var i = 0; i < height; i++)
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
for (var j = 0; j < width; j++)
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
*pDest++ = *pSrc;
|
||||
pSrc += channelCount;
|
||||
|
@ -9,9 +9,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework
|
||||
{
|
||||
public class OutputStreamPoller<T> : MpResourceHandle
|
||||
public unsafe class OutputStreamPoller<T> : MpResourceHandle
|
||||
{
|
||||
public OutputStreamPoller(IntPtr ptr) : base(ptr) { }
|
||||
public OutputStreamPoller(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr()
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class Anchor3dVectorPacket : Packet<List<Anchor3d>>
|
||||
public unsafe class Anchor3dVectorPacket : Packet<List<Anchor3d>>
|
||||
{
|
||||
public Anchor3dVectorPacket() : base() { }
|
||||
public Anchor3dVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class BoolPacket : Packet<bool>
|
||||
public unsafe class BoolPacket : Packet<bool>
|
||||
{
|
||||
public BoolPacket() : base() { }
|
||||
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class ClassificationListPacket : Packet<ClassificationList>
|
||||
public unsafe class ClassificationListPacket : Packet<ClassificationList>
|
||||
{
|
||||
public ClassificationListPacket() : base() { }
|
||||
public ClassificationListPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class ClassificationListVectorPacket : Packet<List<ClassificationList>>
|
||||
public unsafe class ClassificationListVectorPacket : Packet<List<ClassificationList>>
|
||||
{
|
||||
public ClassificationListVectorPacket() : base() { }
|
||||
public ClassificationListVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class DetectionPacket : Packet<Detection>
|
||||
public unsafe class DetectionPacket : Packet<Detection>
|
||||
{
|
||||
public DetectionPacket() : base() { }
|
||||
public DetectionPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class DetectionVectorPacket : Packet<List<Detection>>
|
||||
public unsafe class DetectionVectorPacket : Packet<List<Detection>>
|
||||
{
|
||||
public DetectionVectorPacket() : base() { }
|
||||
public DetectionVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class FaceGeometryPacket : Packet<FaceGeometry.FaceGeometry>
|
||||
public unsafe class FaceGeometryPacket : Packet<FaceGeometry.FaceGeometry>
|
||||
{
|
||||
public FaceGeometryPacket() : base() { }
|
||||
public FaceGeometryPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class FaceGeometryVectorPacket : Packet<List<FaceGeometry.FaceGeometry>>
|
||||
public unsafe class FaceGeometryVectorPacket : Packet<List<FaceGeometry.FaceGeometry>>
|
||||
{
|
||||
public FaceGeometryVectorPacket() : base() { }
|
||||
public FaceGeometryVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -5,10 +5,11 @@
|
||||
using System;
|
||||
using Mediapipe.Net.Framework.Port;
|
||||
using Mediapipe.Net.Native;
|
||||
using Mediapipe.Net.Util;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class FloatArrayPacket : Packet<float[]>
|
||||
public unsafe class FloatArrayPacket : Packet<float[]>
|
||||
{
|
||||
private int length = -1;
|
||||
|
||||
@ -48,26 +49,14 @@ namespace Mediapipe.Net.Framework.Packet
|
||||
if (Length < 0)
|
||||
throw new InvalidOperationException("The array's length is unknown, set Length first");
|
||||
|
||||
var result = new float[Length];
|
||||
|
||||
unsafe
|
||||
{
|
||||
var src = (float*)GetArrayPtr();
|
||||
|
||||
for (var i = 0; i < result.Length; i++)
|
||||
{
|
||||
result[i] = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return UnsafeUtil.SafeArrayCopy(GetArrayPtr(), Length);
|
||||
}
|
||||
|
||||
public IntPtr GetArrayPtr()
|
||||
public float* GetArrayPtr()
|
||||
{
|
||||
UnsafeNativeMethods.mp_Packet__GetFloatArray(MpPtr, out var value).Assert();
|
||||
UnsafeNativeMethods.mp_Packet__GetFloatArray(MpPtr, out float* array).Assert();
|
||||
GC.KeepAlive(this);
|
||||
return value;
|
||||
return array;
|
||||
}
|
||||
|
||||
public override StatusOr<float[]> Consume() => throw new NotSupportedException();
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class FloatPacket : Packet<float>
|
||||
public unsafe class FloatPacket : Packet<float>
|
||||
{
|
||||
public FloatPacket() : base() { }
|
||||
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe
|
||||
{
|
||||
public class FrameAnnotationPacket : Packet<FrameAnnotation>
|
||||
public unsafe class FrameAnnotationPacket : Packet<FrameAnnotation>
|
||||
{
|
||||
public FrameAnnotationPacket() : base() { }
|
||||
public FrameAnnotationPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class GpuBufferPacket : Packet<GpuBuffer>
|
||||
public unsafe class GpuBufferPacket : Packet<GpuBuffer>
|
||||
{
|
||||
public GpuBufferPacket() : base() { }
|
||||
public GpuBufferPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class ImageFramePacket : Packet<ImageFrame>
|
||||
public unsafe class ImageFramePacket : Packet<ImageFrame>
|
||||
{
|
||||
public ImageFramePacket() : base() { }
|
||||
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class IntPacket : Packet<int>
|
||||
public unsafe class IntPacket : Packet<int>
|
||||
{
|
||||
public IntPacket() : base() { }
|
||||
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class LandmarkListPacket : Packet<LandmarkList>
|
||||
public unsafe class LandmarkListPacket : Packet<LandmarkList>
|
||||
{
|
||||
public LandmarkListPacket() : base() { }
|
||||
public LandmarkListPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class LandmarkListVectorPacket : Packet<List<LandmarkList>>
|
||||
public unsafe class LandmarkListVectorPacket : Packet<List<LandmarkList>>
|
||||
{
|
||||
public LandmarkListVectorPacket() : base() { }
|
||||
public LandmarkListVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class NormalizedLandmarkListPacket : Packet<NormalizedLandmarkList>
|
||||
public unsafe class NormalizedLandmarkListPacket : Packet<NormalizedLandmarkList>
|
||||
{
|
||||
public NormalizedLandmarkListPacket() : base() { }
|
||||
public NormalizedLandmarkListPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class NormalizedLandmarkListVectorPacket : Packet<List<NormalizedLandmarkList>>
|
||||
public unsafe class NormalizedLandmarkListVectorPacket : Packet<List<NormalizedLandmarkList>>
|
||||
{
|
||||
public NormalizedLandmarkListVectorPacket() : base() { }
|
||||
public NormalizedLandmarkListVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class NormalizedRectPacket : Packet<NormalizedRect>
|
||||
public unsafe class NormalizedRectPacket : Packet<NormalizedRect>
|
||||
{
|
||||
public NormalizedRectPacket() : base() { }
|
||||
public NormalizedRectPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class NormalizedRectVectorPacket : Packet<List<NormalizedRect>>
|
||||
public unsafe class NormalizedRectVectorPacket : Packet<List<NormalizedRect>>
|
||||
{
|
||||
public NormalizedRectVectorPacket() : base() { }
|
||||
public NormalizedRectVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public abstract class Packet<T> : MpResourceHandle
|
||||
public unsafe abstract class Packet<T> : MpResourceHandle
|
||||
{
|
||||
public Packet() : base()
|
||||
{
|
||||
@ -17,9 +17,12 @@ namespace Mediapipe.Net.Framework.Packet
|
||||
Ptr = ptr;
|
||||
}
|
||||
|
||||
public Packet(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public Packet(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
/// <exception cref="MediaPipeException">Thrown when the value is not set</exception>
|
||||
// Temp backwards compatibility until we find something better than the Activator. ¬¬
|
||||
public Packet(IntPtr ptr, bool isOwner = true) : base((void*)ptr, isOwner) { }
|
||||
|
||||
/// <exception cref="MediapipeException">Thrown when the value is not set</exception>
|
||||
public abstract T Get();
|
||||
|
||||
public abstract StatusOr<T> Consume();
|
||||
@ -29,14 +32,13 @@ namespace Mediapipe.Net.Framework.Packet
|
||||
public Packet<T>? At(Timestamp timestamp)
|
||||
{
|
||||
UnsafeNativeMethods.mp_Packet__At__Rt(MpPtr, timestamp.MpPtr, out var packetPtr).Assert();
|
||||
|
||||
GC.KeepAlive(timestamp);
|
||||
|
||||
// Oh gosh... the Activator...
|
||||
return (Packet<T>?)Activator.CreateInstance(GetType(), packetPtr, true);
|
||||
return (Packet<T>?)Activator.CreateInstance(GetType(), (IntPtr)packetPtr, true);
|
||||
}
|
||||
|
||||
public bool IsEmpty() => SafeNativeMethods.mp_Packet__IsEmpty(MpPtr);
|
||||
public bool IsEmpty() => SafeNativeMethods.mp_Packet__IsEmpty(MpPtr) > 0;
|
||||
|
||||
public Status ValidateAsProtoMessageLite()
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class RectPacket : Packet<Rect>
|
||||
public unsafe class RectPacket : Packet<Rect>
|
||||
{
|
||||
public RectPacket() : base() { }
|
||||
public RectPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -10,7 +10,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class RectVectorPacket : Packet<List<Rect>>
|
||||
public unsafe class RectVectorPacket : Packet<List<Rect>>
|
||||
{
|
||||
public RectVectorPacket() : base() { }
|
||||
public RectVectorPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class SidePacket : MpResourceHandle
|
||||
public unsafe class SidePacket : MpResourceHandle
|
||||
{
|
||||
public SidePacket() : base()
|
||||
{
|
||||
@ -26,13 +26,13 @@ namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
UnsafeNativeMethods.mp_SidePacket__at__PKc(MpPtr, key, out var packetPtr).Assert();
|
||||
|
||||
if (packetPtr == IntPtr.Zero)
|
||||
if (packetPtr == null)
|
||||
return default; // null
|
||||
|
||||
GC.KeepAlive(this);
|
||||
|
||||
// Oh gosh²... the Activator²...
|
||||
return (T?)Activator.CreateInstance(typeof(T), packetPtr, true);
|
||||
return (T?)Activator.CreateInstance(typeof(T), (IntPtr)packetPtr, true);
|
||||
}
|
||||
|
||||
public void Emplace<T>(string key, Packet<T> packet)
|
||||
|
@ -3,13 +3,13 @@
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Framework.Port;
|
||||
using Mediapipe.Net.Native;
|
||||
using Mediapipe.Net.Util;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class StringPacket : Packet<string>
|
||||
public unsafe class StringPacket : Packet<string>
|
||||
{
|
||||
public StringPacket() : base() { }
|
||||
|
||||
@ -49,8 +49,7 @@ namespace Mediapipe.Net.Framework.Packet
|
||||
UnsafeNativeMethods.mp_Packet__GetByteString(MpPtr, out var strPtr, out var size).Assert();
|
||||
GC.KeepAlive(this);
|
||||
|
||||
var bytes = new byte[size];
|
||||
Marshal.Copy(strPtr, bytes, 0, size);
|
||||
byte[] bytes = UnsafeUtil.SafeArrayCopy((byte*)strPtr, size);
|
||||
UnsafeNativeMethods.delete_array__PKc(strPtr);
|
||||
|
||||
return bytes;
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Packet
|
||||
{
|
||||
public class TimedModelMatrixProtoListPacket : Packet<TimedModelMatrixProtoList>
|
||||
public unsafe class TimedModelMatrixProtoListPacket : Packet<TimedModelMatrixProtoList>
|
||||
{
|
||||
public TimedModelMatrixProtoListPacket() : base() { }
|
||||
public TimedModelMatrixProtoListPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
@ -2,13 +2,12 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using Mediapipe.Net.Core;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public class Status : MpResourceHandle
|
||||
public unsafe class Status : MpResourceHandle
|
||||
{
|
||||
public enum StatusCode : int
|
||||
{
|
||||
@ -31,7 +30,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
Unauthenticated = 16,
|
||||
}
|
||||
|
||||
public Status(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public Status(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.absl_Status__delete(Ptr);
|
||||
|
||||
@ -48,7 +47,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
if (ok is bool valueOfOk)
|
||||
return valueOfOk;
|
||||
ok = SafeNativeMethods.absl_Status__ok(MpPtr);
|
||||
ok = SafeNativeMethods.absl_Status__ok(MpPtr) > 0;
|
||||
return (bool)ok;
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,13 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using Mediapipe.Net.Core;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public abstract class StatusOr<T> : MpResourceHandle
|
||||
public unsafe abstract class StatusOr<T> : MpResourceHandle
|
||||
{
|
||||
public StatusOr(IntPtr ptr) : base(ptr) { }
|
||||
public StatusOr(void* ptr) : base(ptr) { }
|
||||
|
||||
public abstract Status Status { get; }
|
||||
public virtual bool Ok() => Status.Ok();
|
||||
|
@ -8,9 +8,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public class StatusOrGpuBuffer : StatusOr<GpuBuffer>
|
||||
public unsafe class StatusOrGpuBuffer : StatusOr<GpuBuffer>
|
||||
{
|
||||
public StatusOrGpuBuffer(IntPtr ptr) : base(ptr) { }
|
||||
public StatusOrGpuBuffer(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_StatusOrGpuBuffer__delete(Ptr);
|
||||
|
||||
@ -30,7 +30,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrGpuBuffer__ok(MpPtr);
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrGpuBuffer__ok(MpPtr) > 0;
|
||||
|
||||
public override GpuBuffer Value()
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public class StatusOrGpuResources : StatusOr<GpuResources>
|
||||
public unsafe class StatusOrGpuResources : StatusOr<GpuResources>
|
||||
{
|
||||
public StatusOrGpuResources(IntPtr ptr) : base(ptr) { }
|
||||
public StatusOrGpuResources(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr()
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrGpuResources__ok(MpPtr);
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrGpuResources__ok(MpPtr) > 0;
|
||||
|
||||
public override GpuResources Value()
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public class StatusOrImageFrame : StatusOr<ImageFrame>
|
||||
public unsafe class StatusOrImageFrame : StatusOr<ImageFrame>
|
||||
{
|
||||
public StatusOrImageFrame(IntPtr ptr) : base(ptr) { }
|
||||
public StatusOrImageFrame(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr()
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrImageFrame__ok(MpPtr);
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrImageFrame__ok(MpPtr) > 0;
|
||||
|
||||
public override ImageFrame Value()
|
||||
{
|
||||
|
@ -7,9 +7,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework.Port
|
||||
{
|
||||
public class StatusOrPoller<T> : StatusOr<OutputStreamPoller<T>>
|
||||
public unsafe class StatusOrPoller<T> : StatusOr<OutputStreamPoller<T>>
|
||||
{
|
||||
public StatusOrPoller(IntPtr ptr) : base(ptr) { }
|
||||
public StatusOrPoller(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_StatusOrPoller__delete(Ptr);
|
||||
|
||||
@ -29,7 +29,7 @@ namespace Mediapipe.Net.Framework.Port
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrPoller__ok(MpPtr);
|
||||
public override bool Ok() => SafeNativeMethods.mp_StatusOrPoller__ok(MpPtr) > 0;
|
||||
|
||||
public override OutputStreamPoller<T> Value()
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Framework
|
||||
{
|
||||
public class Timestamp : MpResourceHandle, IEquatable<Timestamp>
|
||||
public unsafe class Timestamp : MpResourceHandle, IEquatable<Timestamp>
|
||||
{
|
||||
public Timestamp(IntPtr ptr) : base(ptr) { }
|
||||
public Timestamp(void* ptr) : base(ptr) { }
|
||||
|
||||
public Timestamp(long value) : base()
|
||||
{
|
||||
@ -45,11 +45,11 @@ namespace Mediapipe.Net.Framework
|
||||
|
||||
public long Microseconds => SafeNativeMethods.mp_Timestamp__Microseconds(MpPtr);
|
||||
|
||||
public bool IsSpecialValue => SafeNativeMethods.mp_Timestamp__IsSpecialValue(MpPtr);
|
||||
public bool IsSpecialValue => SafeNativeMethods.mp_Timestamp__IsSpecialValue(MpPtr) > 0;
|
||||
|
||||
public bool IsRangeValue => SafeNativeMethods.mp_Timestamp__IsRangeValue(MpPtr);
|
||||
public bool IsRangeValue => SafeNativeMethods.mp_Timestamp__IsRangeValue(MpPtr) > 0;
|
||||
|
||||
public bool IsAllowedInStream => SafeNativeMethods.mp_Timestamp__IsAllowedInStream(MpPtr);
|
||||
public bool IsAllowedInStream => SafeNativeMethods.mp_Timestamp__IsAllowedInStream(MpPtr) > 0;
|
||||
|
||||
public string? DebugString => MarshalStringFromNative(UnsafeNativeMethods.mp_Timestamp__DebugString);
|
||||
|
||||
|
@ -2,15 +2,14 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
public class Egl
|
||||
public unsafe class Egl
|
||||
{
|
||||
public static IntPtr GetCurrentContext() => SafeNativeMethods.eglGetCurrentContext();
|
||||
public static void* GetCurrentContext() => SafeNativeMethods.eglGetCurrentContext();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
@ -13,7 +12,7 @@ namespace Mediapipe.Net.Gpu
|
||||
|
||||
public static void Flush() => UnsafeNativeMethods.glFlush();
|
||||
|
||||
public static void ReadPixels(int x, int y, int width, int height, uint glFormat, uint glType, IntPtr pixels)
|
||||
public unsafe static void ReadPixels(int x, int y, int width, int height, uint glFormat, uint glType, void* pixels)
|
||||
=> UnsafeNativeMethods.glReadPixels(x, y, width, height, glFormat, glType, pixels);
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GlCalculatorHelper : MpResourceHandle
|
||||
public unsafe class GlCalculatorHelper : MpResourceHandle
|
||||
{
|
||||
public delegate IntPtr NativeGlStatusFunction();
|
||||
public delegate void* NativeGlStatusFunction();
|
||||
public delegate Status GlStatusFunction();
|
||||
|
||||
public GlCalculatorHelper() : base()
|
||||
@ -138,6 +138,6 @@ namespace Mediapipe.Net.Gpu
|
||||
return new GlContext(glContextPtr, false);
|
||||
}
|
||||
|
||||
public bool Initialized() => SafeNativeMethods.mp_GlCalculatorHelper__Initialized(MpPtr);
|
||||
public bool Initialized() => SafeNativeMethods.mp_GlCalculatorHelper__Initialized(MpPtr) > 0;
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,23 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using Mediapipe.Net.Core;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GlContext : MpResourceHandle
|
||||
public unsafe class GlContext : MpResourceHandle
|
||||
{
|
||||
private SharedPtrHandle? sharedPtrHandle;
|
||||
|
||||
public static GlContext? GetCurrent()
|
||||
{
|
||||
UnsafeNativeMethods.mp_GlContext_GetCurrent(out var glContextPtr).Assert();
|
||||
return glContextPtr == IntPtr.Zero ? null : new GlContext(glContextPtr);
|
||||
return glContextPtr == null ? null : new GlContext(glContextPtr);
|
||||
}
|
||||
|
||||
public GlContext(IntPtr ptr, bool isOwner = true) : base(isOwner)
|
||||
public GlContext(void* ptr, bool isOwner = true) : base(isOwner)
|
||||
{
|
||||
sharedPtrHandle = new SharedGlContextPtr(ptr, isOwner);
|
||||
Ptr = sharedPtrHandle.Get();
|
||||
@ -40,25 +39,25 @@ namespace Mediapipe.Net.Gpu
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public IntPtr SharedPtr => sharedPtrHandle == null ? IntPtr.Zero : sharedPtrHandle.MpPtr;
|
||||
public void* SharedPtr => sharedPtrHandle == null ? null : sharedPtrHandle.MpPtr;
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
public IntPtr EglDisplay => SafeNativeMethods.mp_GlContext__egl_display(MpPtr);
|
||||
public void* EglDisplay => SafeNativeMethods.mp_GlContext__egl_display(MpPtr);
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
public IntPtr EglConfig => SafeNativeMethods.mp_GlContext__egl_config(MpPtr);
|
||||
public void* EglConfig => SafeNativeMethods.mp_GlContext__egl_config(MpPtr);
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
public IntPtr EglContext => SafeNativeMethods.mp_GlContext__egl_context(MpPtr);
|
||||
public void* EglContext => SafeNativeMethods.mp_GlContext__egl_context(MpPtr);
|
||||
|
||||
// NOTE: (from homuler) On macOS, native libs cannot be built with GPU enabled, so it cannot be used actually.
|
||||
[SupportedOSPlatform("OSX")]
|
||||
public IntPtr NsglContext => SafeNativeMethods.mp_GlContext__nsgl_context(MpPtr);
|
||||
public void* NsglContext => SafeNativeMethods.mp_GlContext__nsgl_context(MpPtr);
|
||||
|
||||
[SupportedOSPlatform("IOS")]
|
||||
public IntPtr EaglContext => SafeNativeMethods.mp_GlContext__eagl_context(MpPtr);
|
||||
public void* EaglContext => SafeNativeMethods.mp_GlContext__eagl_context(MpPtr);
|
||||
|
||||
public bool IsCurrent() => SafeNativeMethods.mp_GlContext__IsCurrent(MpPtr);
|
||||
public bool IsCurrent() => SafeNativeMethods.mp_GlContext__IsCurrent(MpPtr) > 0;
|
||||
|
||||
public int GlMajorVersion => SafeNativeMethods.mp_GlContext__gl_major_version(MpPtr);
|
||||
|
||||
@ -69,11 +68,11 @@ namespace Mediapipe.Net.Gpu
|
||||
// TODO: Put it in its own file
|
||||
private class SharedGlContextPtr : SharedPtrHandle
|
||||
{
|
||||
public SharedGlContextPtr(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public SharedGlContextPtr(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_SharedGlContext__delete(Ptr);
|
||||
|
||||
public override IntPtr Get() => SafeNativeMethods.mp_SharedGlContext__get(MpPtr);
|
||||
public override void* Get() => SafeNativeMethods.mp_SharedGlContext__get(MpPtr);
|
||||
|
||||
public override void Reset() => UnsafeNativeMethods.mp_SharedGlContext__reset(MpPtr);
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GlSyncPoint : MpResourceHandle
|
||||
public unsafe class GlSyncPoint : MpResourceHandle
|
||||
{
|
||||
private SharedPtrHandle? sharedPtrHandle;
|
||||
|
||||
public GlSyncPoint(IntPtr ptr) : base(ptr)
|
||||
public GlSyncPoint(void* ptr) : base(ptr)
|
||||
{
|
||||
sharedPtrHandle = new SharedGlSyncPointPtr(ptr);
|
||||
Ptr = sharedPtrHandle.Get();
|
||||
@ -33,7 +33,7 @@ namespace Mediapipe.Net.Gpu
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public IntPtr SharedPtr => sharedPtrHandle == null ? IntPtr.Zero : sharedPtrHandle.MpPtr;
|
||||
public void* SharedPtr => sharedPtrHandle == null ? null : sharedPtrHandle.MpPtr;
|
||||
|
||||
public void Wait() => UnsafeNativeMethods.mp_GlSyncPoint__Wait(MpPtr).Assert();
|
||||
|
||||
@ -60,11 +60,11 @@ namespace Mediapipe.Net.Gpu
|
||||
// TODO: Put it in its own file
|
||||
private class SharedGlSyncPointPtr : SharedPtrHandle
|
||||
{
|
||||
public SharedGlSyncPointPtr(IntPtr ptr) : base(ptr) { }
|
||||
public SharedGlSyncPointPtr(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_GlSyncToken__delete(Ptr);
|
||||
|
||||
public override IntPtr Get() => SafeNativeMethods.mp_GlSyncToken__get(MpPtr);
|
||||
public override void* Get() => SafeNativeMethods.mp_GlSyncToken__get(MpPtr);
|
||||
|
||||
public override void Reset() => UnsafeNativeMethods.mp_GlSyncToken__reset(MpPtr);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GlTexture : MpResourceHandle
|
||||
public unsafe class GlTexture : MpResourceHandle
|
||||
{
|
||||
public GlTexture() : base()
|
||||
{
|
||||
@ -16,7 +16,7 @@ namespace Mediapipe.Net.Gpu
|
||||
Ptr = ptr;
|
||||
}
|
||||
|
||||
public GlTexture(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public GlTexture(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_GlTexture__delete(Ptr);
|
||||
|
||||
|
@ -2,13 +2,12 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using Mediapipe.Net.Core;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GlTextureBuffer : MpResourceHandle
|
||||
public unsafe class GlTextureBuffer : MpResourceHandle
|
||||
{
|
||||
private SharedPtrHandle? sharedPtrHandle;
|
||||
|
||||
@ -17,9 +16,9 @@ namespace Mediapipe.Net.Gpu
|
||||
/// However, IL2CPP does not support marshaling delegates that point to instance methods to native code,
|
||||
/// so it receives also the texture name to specify the target instance.
|
||||
/// </remarks>
|
||||
public delegate void DeletionCallback(uint name, IntPtr glSyncToken);
|
||||
public delegate void DeletionCallback(uint name, void* glSyncToken);
|
||||
|
||||
public GlTextureBuffer(IntPtr ptr, bool isOwner = true) : base(isOwner)
|
||||
public GlTextureBuffer(void* ptr, bool isOwner = true) : base(isOwner)
|
||||
{
|
||||
sharedPtrHandle = new SharedGlTextureBufferPtr(ptr, isOwner);
|
||||
Ptr = sharedPtrHandle.Get();
|
||||
@ -32,7 +31,7 @@ namespace Mediapipe.Net.Gpu
|
||||
public GlTextureBuffer(uint target, uint name, int width, int height,
|
||||
GpuBufferFormat format, DeletionCallback callback, GlContext? glContext)
|
||||
{
|
||||
var sharedContextPtr = glContext == null ? IntPtr.Zero : glContext.SharedPtr;
|
||||
var sharedContextPtr = glContext == null ? null : glContext.SharedPtr;
|
||||
UnsafeNativeMethods.mp_SharedGlTextureBuffer__ui_ui_i_i_ui_PF_PSgc(
|
||||
target, name, width, height, format, callback, sharedContextPtr, out var ptr).Assert();
|
||||
|
||||
@ -59,7 +58,7 @@ namespace Mediapipe.Net.Gpu
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public IntPtr SharedPtr => sharedPtrHandle == null ? IntPtr.Zero : sharedPtrHandle.MpPtr;
|
||||
public void* SharedPtr => sharedPtrHandle == null ? null : sharedPtrHandle.MpPtr;
|
||||
|
||||
public uint Name() => SafeNativeMethods.mp_GlTextureBuffer__name(MpPtr);
|
||||
|
||||
@ -90,11 +89,11 @@ namespace Mediapipe.Net.Gpu
|
||||
// TODO: Put it in its own file
|
||||
private class SharedGlTextureBufferPtr : SharedPtrHandle
|
||||
{
|
||||
public SharedGlTextureBufferPtr(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public SharedGlTextureBufferPtr(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_SharedGlTextureBuffer__delete(Ptr);
|
||||
|
||||
public override IntPtr Get() => SafeNativeMethods.mp_SharedGlTextureBuffer__get(MpPtr);
|
||||
public override void* Get() => SafeNativeMethods.mp_SharedGlTextureBuffer__get(MpPtr);
|
||||
|
||||
public override void Reset() => UnsafeNativeMethods.mp_SharedGlTextureBuffer__reset(MpPtr);
|
||||
}
|
||||
|
@ -2,16 +2,15 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using Mediapipe.Net.Core;
|
||||
using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GpuBuffer : MpResourceHandle
|
||||
public unsafe class GpuBuffer : MpResourceHandle
|
||||
{
|
||||
public GpuBuffer(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
public GpuBuffer(void* ptr, bool isOwner = true) : base(ptr, isOwner) { }
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
public GpuBuffer(GlTextureBuffer glTextureBuffer) : base()
|
||||
|
@ -2,7 +2,6 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using Mediapipe.Net.Core;
|
||||
using Mediapipe.Net.Framework.Port;
|
||||
@ -10,12 +9,12 @@ using Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Gpu
|
||||
{
|
||||
public class GpuResources : MpResourceHandle
|
||||
public unsafe class GpuResources : MpResourceHandle
|
||||
{
|
||||
private SharedPtrHandle? sharedPtrHandle;
|
||||
|
||||
/// <param name="ptr">Shared pointer of mediapipe::GpuResources</param>
|
||||
public GpuResources(IntPtr ptr) : base()
|
||||
public GpuResources(void* ptr) : base()
|
||||
{
|
||||
sharedPtrHandle = new SharedGpuResourcesPtr(ptr);
|
||||
Ptr = sharedPtrHandle.Get();
|
||||
@ -36,7 +35,7 @@ namespace Mediapipe.Net.Gpu
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public IntPtr SharedPtr => sharedPtrHandle == null ? IntPtr.Zero : sharedPtrHandle.MpPtr;
|
||||
public void* SharedPtr => sharedPtrHandle == null ? null : sharedPtrHandle.MpPtr;
|
||||
|
||||
public static StatusOrGpuResources Create()
|
||||
{
|
||||
@ -45,7 +44,7 @@ namespace Mediapipe.Net.Gpu
|
||||
return new StatusOrGpuResources(statusOrGpuResourcesPtr);
|
||||
}
|
||||
|
||||
public static StatusOrGpuResources Create(IntPtr externalContext)
|
||||
public static StatusOrGpuResources Create(void* externalContext)
|
||||
{
|
||||
UnsafeNativeMethods.mp_GpuResources_Create__Pv(externalContext, out var statusOrGpuResourcesPtr).Assert();
|
||||
|
||||
@ -53,15 +52,15 @@ namespace Mediapipe.Net.Gpu
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("IOS")]
|
||||
public IntPtr IosGpuData => SafeNativeMethods.mp_GpuResources__ios_gpu_data(MpPtr);
|
||||
public void* IosGpuData => SafeNativeMethods.mp_GpuResources__ios_gpu_data(MpPtr);
|
||||
|
||||
private class SharedGpuResourcesPtr : SharedPtrHandle
|
||||
{
|
||||
public SharedGpuResourcesPtr(IntPtr ptr) : base(ptr) { }
|
||||
public SharedGpuResourcesPtr(void* ptr) : base(ptr) { }
|
||||
|
||||
protected override void DeleteMpPtr() => UnsafeNativeMethods.mp_SharedGpuResources__delete(Ptr);
|
||||
|
||||
public override IntPtr Get() => SafeNativeMethods.mp_SharedGpuResources__get(MpPtr);
|
||||
public override void* Get() => SafeNativeMethods.mp_SharedGpuResources__get(MpPtr);
|
||||
|
||||
public override void Reset() => UnsafeNativeMethods.mp_SharedGpuResources__reset(MpPtr);
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ using Mediapipe.Net.Native;
|
||||
namespace Mediapipe.Net.Graphs.InstantMotionTracking
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct Anchor3dVector : IDisposable
|
||||
internal unsafe struct Anchor3dVector : IDisposable
|
||||
{
|
||||
public IntPtr Data;
|
||||
public Anchor3d* Data;
|
||||
public int Size;
|
||||
|
||||
public void Dispose() => UnsafeNativeMethods.mp_Anchor3dArray__delete(Data);
|
||||
@ -20,14 +20,8 @@ namespace Mediapipe.Net.Graphs.InstantMotionTracking
|
||||
public List<Anchor3d> ToList()
|
||||
{
|
||||
var anchors = new List<Anchor3d>(Size);
|
||||
|
||||
unsafe
|
||||
{
|
||||
var anchorPtr = (Anchor3d*)Data;
|
||||
|
||||
for (var i = 0; i < Size; i++)
|
||||
anchors.Add(Marshal.PtrToStructure<Anchor3d>((IntPtr)anchorPtr++));
|
||||
}
|
||||
for (int i = 0; i < Size; i++)
|
||||
anchors.Add(Data[i]);
|
||||
|
||||
return anchors;
|
||||
}
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
// TODO: (message to future self) Beware of CharSet.Unicode!
|
||||
// If tests fail because of odd string issues, try to marshal strings according to
|
||||
// https://docs.microsoft.com/en-us/dotnet/standard/native-interop/type-marshaling.
|
||||
|
||||
/// <summary>
|
||||
/// Contains all the directly bound native methods from Mediapipe.
|
||||
/// </summary>
|
||||
|
@ -2,19 +2,17 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool absl_Status__ok(IntPtr status);
|
||||
public static extern byte absl_Status__ok(void* status);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int absl_Status__raw_code(IntPtr status);
|
||||
public static extern int absl_Status__raw_code(void* status);
|
||||
}
|
||||
}
|
||||
|
@ -2,34 +2,28 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_CalculatorGraph__HasError(IntPtr graph);
|
||||
public static extern byte mp_CalculatorGraph__HasError(void* graph);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_CalculatorGraph__HasInputStream__PKc(IntPtr graph, string name);
|
||||
public static extern byte mp_CalculatorGraph__HasInputStream__PKc(void* graph, string name);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_CalculatorGraph__GraphInputStreamsClosed(IntPtr graph);
|
||||
public static extern byte mp_CalculatorGraph__GraphInputStreamsClosed(void* graph);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_CalculatorGraph__IsNodeThrottled__i(IntPtr graph, int nodeId);
|
||||
public static extern byte mp_CalculatorGraph__IsNodeThrottled__i(void* graph, int nodeId);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_CalculatorGraph__UnthrottleSources(IntPtr graph);
|
||||
public static extern byte mp_CalculatorGraph__UnthrottleSources(void* graph);
|
||||
#pragma warning restore CA2101
|
||||
}
|
||||
}
|
||||
|
@ -2,61 +2,57 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Framework.Format;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_ImageFrame__IsEmpty(IntPtr imageFrame);
|
||||
public static extern byte mp_ImageFrame__IsEmpty(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_ImageFrame__IsContiguous(IntPtr imageFrame);
|
||||
public static extern byte mp_ImageFrame__IsContiguous(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__IsAligned__ui(
|
||||
IntPtr imageFrame, uint alignmentBoundary, [MarshalAs(UnmanagedType.I1)] out bool value);
|
||||
void* imageFrame, uint alignmentBoundary, out bool value);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern ImageFormat mp_ImageFrame__Format(IntPtr imageFrame);
|
||||
public static extern ImageFormat mp_ImageFrame__Format(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_ImageFrame__Width(IntPtr imageFrame);
|
||||
public static extern int mp_ImageFrame__Width(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_ImageFrame__Height(IntPtr imageFrame);
|
||||
public static extern int mp_ImageFrame__Height(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__ChannelSize(IntPtr imageFrame, out int value);
|
||||
public static extern MpReturnCode mp_ImageFrame__ChannelSize(void* imageFrame, out int value);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__NumberOfChannels(IntPtr imageFrame, out int value);
|
||||
public static extern MpReturnCode mp_ImageFrame__NumberOfChannels(void* imageFrame, out int value);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__ByteDepth(IntPtr imageFrame, out int value);
|
||||
public static extern MpReturnCode mp_ImageFrame__ByteDepth(void* imageFrame, out int value);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_ImageFrame__WidthStep(IntPtr imageFrame);
|
||||
public static extern int mp_ImageFrame__WidthStep(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_ImageFrame__MutablePixelData(IntPtr imageFrame);
|
||||
public static extern byte* mp_ImageFrame__MutablePixelData(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_ImageFrame__PixelDataSize(IntPtr imageFrame);
|
||||
public static extern int mp_ImageFrame__PixelDataSize(void* imageFrame);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__PixelDataSizeStoredContiguously(IntPtr imageFrame, out int value);
|
||||
public static extern MpReturnCode mp_ImageFrame__PixelDataSizeStoredContiguously(void* imageFrame, out int value);
|
||||
|
||||
#region StatusOr
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_StatusOrImageFrame__ok(IntPtr statusOrImageFrame);
|
||||
public static extern byte mp_StatusOrImageFrame__ok(void* statusOrImageFrame);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,14 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_StatusOrPoller__ok(IntPtr statusOrPoller);
|
||||
public static extern byte mp_StatusOrPoller__ok(void* statusOrPoller);
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,20 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_Packet__IsEmpty(IntPtr packet);
|
||||
public static extern byte mp_Packet__IsEmpty(void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SidePacket__clear(IntPtr sidePacket);
|
||||
public static extern void mp_SidePacket__clear(void* sidePacket);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_SidePacket__size(IntPtr sidePacket);
|
||||
public static extern int mp_SidePacket__size(void* sidePacket);
|
||||
}
|
||||
}
|
||||
|
@ -2,33 +2,29 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern long mp_Timestamp__Value(IntPtr timestamp);
|
||||
public static extern long mp_Timestamp__Value(void* timestamp);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern double mp_Timestamp__Seconds(IntPtr timestamp);
|
||||
public static extern double mp_Timestamp__Seconds(void* timestamp);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern long mp_Timestamp__Microseconds(IntPtr timestamp);
|
||||
public static extern long mp_Timestamp__Microseconds(void* timestamp);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_Timestamp__IsSpecialValue(IntPtr timestamp);
|
||||
public static extern byte mp_Timestamp__IsSpecialValue(void* timestamp);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_Timestamp__IsRangeValue(IntPtr timestamp);
|
||||
public static extern byte mp_Timestamp__IsRangeValue(void* timestamp);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_Timestamp__IsAllowedInStream(IntPtr timestamp);
|
||||
public static extern byte mp_Timestamp__IsAllowedInStream(void* timestamp);
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,16 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY)]
|
||||
public static extern IntPtr eglGetCurrentContext();
|
||||
public static extern void* eglGetCurrentContext();
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,20 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern uint mp_GlCalculatorHelper__framebuffer(IntPtr glCalculatorHelper);
|
||||
public static extern uint mp_GlCalculatorHelper__framebuffer(void* glCalculatorHelper);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlCalculatorHelper__GetGlContext(IntPtr glCalculatorHelper);
|
||||
public static extern void* mp_GlCalculatorHelper__GetGlContext(void* glCalculatorHelper);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_GlCalculatorHelper__Initialized(IntPtr glCalculatorHelper);
|
||||
public static extern byte mp_GlCalculatorHelper__Initialized(void* glCalculatorHelper);
|
||||
}
|
||||
}
|
||||
|
@ -2,60 +2,58 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
#region GlContext
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_SharedGlContext__get(IntPtr sharedGlContext);
|
||||
public static extern void* mp_SharedGlContext__get(void* sharedGlContext);
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__egl_display(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__egl_display(void* glContext);
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__egl_config(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__egl_config(void* glContext);
|
||||
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__egl_context(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__egl_context(void* glContext);
|
||||
|
||||
[SupportedOSPlatform("IOS")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__eagl_context(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__eagl_context(void* glContext);
|
||||
|
||||
[SupportedOSPlatform("OSX")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__nsgl_context(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__nsgl_context(void* glContext);
|
||||
|
||||
[SupportedOSPlatform("OSX")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlContext__nsgl_pixel_format(IntPtr glContext);
|
||||
public static extern void* mp_GlContext__nsgl_pixel_format(void* glContext);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_GlContext__IsCurrent(IntPtr glContext);
|
||||
public static extern byte mp_GlContext__IsCurrent(void* glContext);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlContext__gl_major_version(IntPtr glContext);
|
||||
public static extern int mp_GlContext__gl_major_version(void* glContext);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlContext__gl_minor_version(IntPtr glContext);
|
||||
public static extern int mp_GlContext__gl_minor_version(void* glContext);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern long mp_GlContext__gl_finish_count(IntPtr glContext);
|
||||
public static extern long mp_GlContext__gl_finish_count(void* glContext);
|
||||
#endregion
|
||||
|
||||
#region GlSyncToken
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlSyncToken__get(IntPtr glSyncToken);
|
||||
public static extern void* mp_GlSyncToken__get(void* glSyncToken);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,23 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlTexture__width(IntPtr glTexture);
|
||||
public static extern int mp_GlTexture__width(void* glTexture);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlTexture__height(IntPtr glTexture);
|
||||
public static extern int mp_GlTexture__height(void* glTexture);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern uint mp_GlTexture__target(IntPtr glTexture);
|
||||
public static extern uint mp_GlTexture__target(void* glTexture);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern uint mp_GlTexture__name(IntPtr glTexture);
|
||||
public static extern uint mp_GlTexture__name(void* glTexture);
|
||||
}
|
||||
}
|
||||
|
@ -2,38 +2,37 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
#region GlTextureBuffer
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern uint mp_GlTextureBuffer__name(IntPtr glTextureBuffer);
|
||||
public static extern uint mp_GlTextureBuffer__name(void* glTextureBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern uint mp_GlTextureBuffer__target(IntPtr glTextureBuffer);
|
||||
public static extern uint mp_GlTextureBuffer__target(void* glTextureBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlTextureBuffer__width(IntPtr glTextureBuffer);
|
||||
public static extern int mp_GlTextureBuffer__width(void* glTextureBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GlTextureBuffer__height(IntPtr glTextureBuffer);
|
||||
public static extern int mp_GlTextureBuffer__height(void* glTextureBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern GpuBufferFormat mp_GlTextureBuffer__format(IntPtr glTextureBuffer);
|
||||
public static extern GpuBufferFormat mp_GlTextureBuffer__format(void* glTextureBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GlTextureBuffer__GetProducerContext(IntPtr glTextureBuffer);
|
||||
public static extern void* mp_GlTextureBuffer__GetProducerContext(void* glTextureBuffer);
|
||||
#endregion
|
||||
|
||||
#region SharedGlTextureBuffer
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_SharedGlTextureBuffer__get(IntPtr glTextureBuffer);
|
||||
public static extern void* mp_SharedGlTextureBuffer__get(void* glTextureBuffer);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
@ -10,25 +9,24 @@ using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GpuBuffer__GetGlTextureBufferSharedPtr(IntPtr gpuBuffer);
|
||||
public static extern void* mp_GpuBuffer__GetGlTextureBufferSharedPtr(void* gpuBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GpuBuffer__width(IntPtr gpuBuffer);
|
||||
public static extern int mp_GpuBuffer__width(void* gpuBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern int mp_GpuBuffer__height(IntPtr gpuBuffer);
|
||||
public static extern int mp_GpuBuffer__height(void* gpuBuffer);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern GpuBufferFormat mp_GpuBuffer__format(IntPtr gpuBuffer);
|
||||
public static extern GpuBufferFormat mp_GpuBuffer__format(void* gpuBuffer);
|
||||
|
||||
#region StatusOr
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_StatusOrGpuBuffer__ok(IntPtr statusOrGpuBuffer);
|
||||
public static extern byte mp_StatusOrGpuBuffer__ok(void* statusOrGpuBuffer);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern ImageFormat mp__ImageFormatForGpuBufferFormat__ui(GpuBufferFormat format);
|
||||
|
@ -2,24 +2,22 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[SupportedOSPlatform("IOS")]
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_GpuResources__ios_gpu_data(IntPtr gpuResources);
|
||||
public static extern void* mp_GpuResources__ios_gpu_data(void* gpuResources);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern IntPtr mp_SharedGpuResources__get(IntPtr gpuResources);
|
||||
public static extern void* mp_SharedGpuResources__get(void* gpuResources);
|
||||
|
||||
[Pure, DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_StatusOrGpuResources__ok(IntPtr statusOrGpuResources);
|
||||
public static extern byte mp_StatusOrGpuResources__ok(void* statusOrGpuResources);
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ using Mediapipe.Net.Util;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class SafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class SafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp__SetCustomGlobalResourceProvider__P(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] ResourceManager.ResourceProvider provider);
|
||||
ResourceManager.ResourceProvider provider);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp__SetCustomGlobalPathResolver__P(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] ResourceManager.PathResolver resolver);
|
||||
ResourceManager.PathResolver resolver);
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,21 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode absl_Status__i_PKc(int code, string message, out IntPtr status);
|
||||
public static extern MpReturnCode absl_Status__i_PKc(int code, string message, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void absl_Status__delete(IntPtr status);
|
||||
public static extern void absl_Status__delete(void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode absl_Status__ToString(IntPtr status, out IntPtr str);
|
||||
public static extern MpReturnCode absl_Status__ToString(void* status, out sbyte* str);
|
||||
#pragma warning restore CA2101
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using Mediapipe.Net.External;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
@ -17,7 +17,7 @@ namespace Mediapipe.Net.Native
|
||||
public static extern MpReturnCode google_ShutdownGoogleLogging();
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void glog_FLAGS_logtostderr([MarshalAs(UnmanagedType.I1)] bool value);
|
||||
public static extern void glog_FLAGS_logtostderr(bool value);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void glog_FLAGS_stderrthreshold(int threshold);
|
||||
|
@ -2,69 +2,68 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.External;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode google_protobuf__SetLogHandler__PF(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] Protobuf.ProtobufLogHandler logHandler);
|
||||
Protobuf.ProtobufLogHandler logHandler);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_api_SerializedProtoArray__delete(IntPtr serializedProtoVectorData);
|
||||
public static extern void mp_api_SerializedProtoArray__delete(void* serializedProtoVectorData);
|
||||
|
||||
#region MessageProto
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetClassificationList(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetClassificationList(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetClassificationListVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetClassificationListVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetDetection(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetDetection(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetDetectionVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetDetectionVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetFaceGeometry(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetFaceGeometry(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetFaceGeometryVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetFaceGeometryVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetFrameAnnotation(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetFrameAnnotation(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetLandmarkList(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetLandmarkList(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetLandmarkListVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetLandmarkListVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedLandmarkList(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedLandmarkList(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedLandmarkListVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedLandmarkListVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedRect(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedRect(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedRectVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetNormalizedRectVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetRect(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetRect(void* packet, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetRectVector(IntPtr packet, out SerializedProtoVector serializedProtoVector);
|
||||
public static extern MpReturnCode mp_Packet__GetRectVector(void* packet, out SerializedProtoVector serializedProtoVector);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetTimedModelMatrixProtoList(IntPtr packet, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_Packet__GetTimedModelMatrixProtoList(void* packet, out SerializedProto serializedProto);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,25 +2,24 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void delete_array__PKc(IntPtr str);
|
||||
public static extern void delete_array__PKc(sbyte* str);
|
||||
|
||||
#region String
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void std_string__delete(IntPtr str);
|
||||
public static extern void std_string__delete(sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode std_string__PKc_i(byte[] bytes, int size, out IntPtr str);
|
||||
public static extern MpReturnCode std_string__PKc_i(byte[] bytes, int size, out sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void std_string__swap__Rstr(IntPtr src, IntPtr dst);
|
||||
public static extern void std_string__swap__Rstr(void* src, void* dst);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,11 @@ using Mediapipe.Net.External;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool mp_api__ConvertFromCalculatorGraphConfigTextFormat(string configText, out SerializedProto serializedProto);
|
||||
public static extern byte mp_api__ConvertFromCalculatorGraphConfigTextFormat(string configText, out SerializedProto serializedProto);
|
||||
#pragma warning restore CA2101
|
||||
}
|
||||
}
|
||||
|
@ -2,81 +2,81 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.External;
|
||||
using Mediapipe.Net.Framework;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__(out IntPtr graph);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__(out void* graph);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__PKc(string textFormatConfig, out IntPtr graph);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__PKc(string textFormatConfig, out void* graph);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__PKc_i(byte[] serializedConfig, int size, out IntPtr graph);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__PKc_i(byte[] serializedConfig, int size, out void* graph);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_CalculatorGraph__delete(IntPtr graph);
|
||||
public static extern void mp_CalculatorGraph__delete(void* graph);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Initialize__PKc_i(IntPtr graph, byte[] serializedConfig, int size, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Initialize__PKc_i(void* graph, byte[] serializedConfig, int size, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Initialize__PKc_i_Rsp(
|
||||
IntPtr graph, byte[] serializedConfig, int size, IntPtr sidePackets, out IntPtr status);
|
||||
void* graph, byte[] serializedConfig, int size, void* sidePackets, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Config(IntPtr graph, out SerializedProto serializedProto);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Config(void* graph, out SerializedProto serializedProto);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__ObserveOutputStream__PKc_PF_b(IntPtr graph, string streamName,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] CalculatorGraph.NativePacketCallback packetCallback,
|
||||
[MarshalAs(UnmanagedType.I1)] bool observeTimestampBounds, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__ObserveOutputStream__PKc_PF_b(void* graph, string streamName,
|
||||
CalculatorGraph.NativePacketCallback packetCallback,
|
||||
bool observeTimestampBounds, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__AddOutputStreamPoller__PKc_b(IntPtr graph, string streamName, [MarshalAs(UnmanagedType.I1)] bool observeTimestampBounds, out IntPtr statusOrPoller);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__AddOutputStreamPoller__PKc_b(void* graph, string streamName,
|
||||
bool observeTimestampBounds, out void* statusOrPoller);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Run__Rsp(IntPtr graph, IntPtr sidePackets, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Run__Rsp(void* graph, void* sidePackets, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__StartRun__Rsp(IntPtr graph, IntPtr sidePackets, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__StartRun__Rsp(void* graph, void* sidePackets, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__WaitUntilIdle(IntPtr graph, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__WaitUntilIdle(void* graph, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__WaitUntilDone(IntPtr graph, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__WaitUntilDone(void* graph, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__AddPacketToInputStream__PKc_Ppacket(
|
||||
IntPtr graph, string streamName, IntPtr packet, out IntPtr status);
|
||||
void* graph, string streamName, void* packet, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__SetInputStreamMaxQueueSize__PKc_i(
|
||||
IntPtr graph, string streamName, int maxQueueSize, out IntPtr status);
|
||||
void* graph, string streamName, int maxQueueSize, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__CloseInputStream__PKc(IntPtr graph, string streamName, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__CloseInputStream__PKc(void* graph, string streamName, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__CloseAllPacketSources(IntPtr graph, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__CloseAllPacketSources(void* graph, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Cancel(IntPtr graph);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__Cancel(void* graph);
|
||||
|
||||
#region GPU
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__GetGpuResources(IntPtr graph, out IntPtr gpuResources);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__GetGpuResources(void* graph, out void* gpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_CalculatorGraph__SetGpuResources__SPgpu(IntPtr graph, IntPtr gpuResources, out IntPtr status);
|
||||
public static extern MpReturnCode mp_CalculatorGraph__SetGpuResources__SPgpu(void* graph, void* gpuResources, out void* status);
|
||||
#endregion
|
||||
#pragma warning restore CA2101
|
||||
}
|
||||
|
@ -2,72 +2,69 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Framework.Format;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__(out IntPtr imageFrame);
|
||||
public static extern MpReturnCode mp_ImageFrame__(out void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__ui_i_i_ui(
|
||||
ImageFormat format, int width, int height, uint alignmentBoundary, out IntPtr imageFrame);
|
||||
ImageFormat format, int width, int height, uint alignmentBoundary, out void* imageFrame);
|
||||
|
||||
// TODO: Make it be a member of ImageFrame
|
||||
public delegate void Deleter(IntPtr ptr);
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__ui_i_i_i_Pui8_PF(
|
||||
ImageFormat format, int width, int height, int widthStep, IntPtr pixelData,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] Deleter deleter, out IntPtr imageFrame);
|
||||
ImageFormat format, int width, int height, int widthStep, byte* pixelData,
|
||||
ImageFrame.Deleter deleter, out void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_ImageFrame__delete(IntPtr imageFrame);
|
||||
public static extern void mp_ImageFrame__delete(void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__SetToZero(IntPtr imageFrame);
|
||||
public static extern MpReturnCode mp_ImageFrame__SetToZero(void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__SetAlignmentPaddingAreas(IntPtr imageFrame);
|
||||
public static extern MpReturnCode mp_ImageFrame__SetAlignmentPaddingAreas(void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui8_i(IntPtr imageFrame, IntPtr buffer, int bufferSize);
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui8_i(void* imageFrame, byte* buffer, int bufferSize);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui16_i(IntPtr imageFrame, IntPtr buffer, int bufferSize);
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui16_i(void* imageFrame, ushort* buffer, int bufferSize);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pf_i(IntPtr imageFrame, IntPtr buffer, int bufferSize);
|
||||
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pf_i(void* imageFrame, float* buffer, int bufferSize);
|
||||
|
||||
#region StatusOr
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_StatusOrImageFrame__delete(IntPtr statusOrImageFrame);
|
||||
public static extern void mp_StatusOrImageFrame__delete(void* statusOrImageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrImageFrame__status(IntPtr statusOrImageFrame, out IntPtr status);
|
||||
public static extern MpReturnCode mp_StatusOrImageFrame__status(void* statusOrImageFrame, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrImageFrame__value(IntPtr statusOrImageFrame, out IntPtr imageFrame);
|
||||
public static extern MpReturnCode mp_StatusOrImageFrame__value(void* statusOrImageFrame, out void* imageFrame);
|
||||
#endregion
|
||||
|
||||
#region Packet
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeImageFramePacket__Pif(IntPtr imageFrame, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeImageFramePacket__Pif(void* imageFrame, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeImageFramePacket_At__Pif_Rt(IntPtr imageFrame, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeImageFramePacket_At__Pif_Rt(void* imageFrame, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ConsumeImageFrame(IntPtr packet, out IntPtr statusOrImageFrame);
|
||||
public static extern MpReturnCode mp_Packet__ConsumeImageFrame(void* packet, out void* statusOrImageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetImageFrame(IntPtr packet, out IntPtr imageFrame);
|
||||
public static extern MpReturnCode mp_Packet__GetImageFrame(void* packet, out void* imageFrame);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsImageFrame(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsImageFrame(void* packet, out void* status);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,39 +2,38 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#region OutputStreamPoller
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_OutputStreamPoller__delete(IntPtr poller);
|
||||
public static extern void mp_OutputStreamPoller__delete(void* poller);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__Reset(IntPtr poller);
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__Reset(void* poller);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__Next_Ppacket(IntPtr poller, IntPtr packet, out bool result);
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__Next_Ppacket(void* poller, void* packet, out bool result);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__SetMaxQueueSize(IntPtr poller, int queueSize);
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__SetMaxQueueSize(void* poller, int queueSize);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__QueueSize(IntPtr poller, out int queueSize);
|
||||
public static extern MpReturnCode mp_OutputStreamPoller__QueueSize(void* poller, out int queueSize);
|
||||
#endregion
|
||||
|
||||
#region StatusOrPoller
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_StatusOrPoller__delete(IntPtr statusOrPoller);
|
||||
public static extern void mp_StatusOrPoller__delete(void* statusOrPoller);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrPoller__status(IntPtr statusOrPoller, out IntPtr status);
|
||||
public static extern MpReturnCode mp_StatusOrPoller__status(void* statusOrPoller, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrPoller__value(IntPtr statusOrPoller, out IntPtr poller);
|
||||
public static extern MpReturnCode mp_StatusOrPoller__value(void* statusOrPoller, out void* poller);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,134 +2,133 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#pragma warning disable CA2101
|
||||
#region common
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__(out IntPtr packet);
|
||||
public static extern MpReturnCode mp_Packet__(out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_Packet__delete(IntPtr packet);
|
||||
public static extern void mp_Packet__delete(void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__At__Rt(IntPtr packet, IntPtr timestamp, out IntPtr newPacket);
|
||||
public static extern MpReturnCode mp_Packet__At__Rt(void* packet, void* timestamp, out void* newPacket);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsProtoMessageLite(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsProtoMessageLite(void* packet, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__Timestamp(IntPtr packet, out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Packet__Timestamp(void* packet, out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__DebugString(IntPtr packet, out IntPtr str);
|
||||
public static extern MpReturnCode mp_Packet__DebugString(void* packet, out sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__RegisteredTypeName(IntPtr packet, out IntPtr str);
|
||||
public static extern MpReturnCode mp_Packet__RegisteredTypeName(void* packet, out sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__DebugTypeName(IntPtr packet, out IntPtr str);
|
||||
public static extern MpReturnCode mp_Packet__DebugTypeName(void* packet, out sbyte* str);
|
||||
#endregion
|
||||
|
||||
#region Bool
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeBoolPacket__b([MarshalAs(UnmanagedType.I1)] bool value, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeBoolPacket__b(bool value, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeBoolPacket_At__b_Rt([MarshalAs(UnmanagedType.I1)] bool value, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeBoolPacket_At__b_Rt(bool value, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetBool(IntPtr packet, [MarshalAs(UnmanagedType.I1)] out bool value);
|
||||
public static extern MpReturnCode mp_Packet__GetBool(void* packet, out bool value);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsBool(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsBool(void* packet, out void* status);
|
||||
#endregion
|
||||
|
||||
#region Float
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeFloatPacket__f(float value, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeFloatPacket__f(float value, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeFloatPacket_At__f_Rt(float value, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeFloatPacket_At__f_Rt(float value, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetFloat(IntPtr packet, out float value);
|
||||
public static extern MpReturnCode mp_Packet__GetFloat(void* packet, out float value);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsFloat(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsFloat(void* packet, out void* status);
|
||||
#endregion
|
||||
|
||||
#region Int
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeIntPacket__i(int value, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeIntPacket__i(int value, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeIntPacket_At__i_Rt(int value, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeIntPacket_At__i_Rt(int value, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetInt(IntPtr packet, out int value);
|
||||
public static extern MpReturnCode mp_Packet__GetInt(void* packet, out int value);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsInt(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsInt(void* packet, out void* status);
|
||||
#endregion
|
||||
|
||||
#region FloatArray
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeFloatArrayPacket__Pf_i(float[] value, int size, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeFloatArrayPacket__Pf_i(float[] value, int size, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeFloatArrayPacket_At__Pf_i_Rt(float[] value, int size, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeFloatArrayPacket_At__Pf_i_Rt(float[] value, int size, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetFloatArray(IntPtr packet, out IntPtr value);
|
||||
public static extern MpReturnCode mp_Packet__GetFloatArray(void* packet, out float* array);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsFloatArray(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsFloatArray(void* packet, out void* status);
|
||||
#endregion
|
||||
|
||||
#region String
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp__MakeStringPacket__PKc(string value, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeStringPacket__PKc(string value, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp__MakeStringPacket_At__PKc_Rt(string value, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeStringPacket_At__PKc_Rt(string value, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeStringPacket__PKc_i(byte[] bytes, int size, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeStringPacket__PKc_i(byte[] bytes, int size, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeStringPacket_At__PKc_i_Rt(byte[] bytes, int size, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeStringPacket_At__PKc_i_Rt(byte[] bytes, int size, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetString(IntPtr packet, out IntPtr value);
|
||||
public static extern MpReturnCode mp_Packet__GetString(void* packet, out sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetByteString(IntPtr packet, out IntPtr value, out int size);
|
||||
public static extern MpReturnCode mp_Packet__GetByteString(void* packet, out sbyte* str, out int size);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsString(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsString(void* packet, out void* status);
|
||||
#endregion
|
||||
|
||||
#region SidePacket
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_SidePacket__(out IntPtr sidePacket);
|
||||
public static extern MpReturnCode mp_SidePacket__(out void* sidePacket);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SidePacket__delete(IntPtr sidePacket);
|
||||
public static extern void mp_SidePacket__delete(void* sidePacket);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_SidePacket__emplace__PKc_Rp(IntPtr sidePacket, string key, IntPtr packet);
|
||||
public static extern MpReturnCode mp_SidePacket__emplace__PKc_Rp(void* sidePacket, string key, void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_SidePacket__at__PKc(IntPtr sidePacket, string key, out IntPtr packet);
|
||||
public static extern MpReturnCode mp_SidePacket__at__PKc(void* sidePacket, string key, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true, CharSet = CharSet.Ansi)]
|
||||
public static extern MpReturnCode mp_SidePacket__erase__PKc(IntPtr sidePacket, string key, out int count);
|
||||
public static extern MpReturnCode mp_SidePacket__erase__PKc(void* sidePacket, string key, out int count);
|
||||
#endregion
|
||||
#pragma warning restore CA2101
|
||||
}
|
||||
|
@ -2,53 +2,52 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp__l(long value, out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp__l(long value, out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_Timestamp__delete(IntPtr timestamp);
|
||||
public static extern void mp_Timestamp__delete(void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp__DebugString(IntPtr timestamp, out IntPtr str);
|
||||
public static extern MpReturnCode mp_Timestamp__DebugString(void* timestamp, out sbyte* str);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp__NextAllowedInStream(IntPtr timestamp, out IntPtr nextTimestamp);
|
||||
public static extern MpReturnCode mp_Timestamp__NextAllowedInStream(void* timestamp, out void* nextTimestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp__PreviousAllowedInStream(IntPtr timestamp, out IntPtr prevTimestamp);
|
||||
public static extern MpReturnCode mp_Timestamp__PreviousAllowedInStream(void* timestamp, out void* prevTimestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_FromSeconds__d(double seconds, out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_FromSeconds__d(double seconds, out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_Unset(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_Unset(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_Unstarted(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_Unstarted(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_PreStream(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_PreStream(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_Min(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_Min(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_Max(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_Max(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_PostStream(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_PostStream(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_OneOverPostStream(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_OneOverPostStream(out void* timestamp);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Timestamp_Done(out IntPtr timestamp);
|
||||
public static extern MpReturnCode mp_Timestamp_Done(out void* timestamp);
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,16 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY)]
|
||||
public static extern void glFlush();
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY)]
|
||||
public static extern void glReadPixels(int x, int y, int width, int height, uint glFormat, uint glType, IntPtr pixels);
|
||||
public static extern void glReadPixels(int x, int y, int width, int height, uint glFormat, uint glType, void* pixels);
|
||||
}
|
||||
}
|
||||
|
@ -2,51 +2,50 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__(out IntPtr glCalculatorHelper);
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__(out void* glCalculatorHelper);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_GlCalculatorHelper__delete(IntPtr glCalculatorHelper);
|
||||
public static extern void mp_GlCalculatorHelper__delete(void* glCalculatorHelper);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__InitializeForTest__Pgr(IntPtr glCalculatorHelper, IntPtr gpuResources);
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__InitializeForTest__Pgr(void* glCalculatorHelper, void* gpuResources);
|
||||
|
||||
// TODO: Make it ba a member of GlCalculatorHelper
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__RunInGlContext__PF(
|
||||
IntPtr glCalculatorHelper, [MarshalAs(UnmanagedType.FunctionPtr)] GlCalculatorHelper.NativeGlStatusFunction glFunc, out IntPtr status);
|
||||
void* glCalculatorHelper, GlCalculatorHelper.NativeGlStatusFunction glFunc, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__CreateSourceTexture__Rif(
|
||||
IntPtr glCalculatorHelper, IntPtr imageFrame, out IntPtr glTexture);
|
||||
void* glCalculatorHelper, void* imageFrame, out void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__CreateSourceTexture__Rgb(
|
||||
IntPtr glCalculatorHelper, IntPtr gpuBuffer, out IntPtr glTexture);
|
||||
void* glCalculatorHelper, void* gpuBuffer, out void* glTexture);
|
||||
|
||||
[SupportedOSPlatform("IOS")]
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__CreateSourceTexture__Rgb_i(
|
||||
IntPtr glCalculatorHelper, IntPtr gpuBuffer, int plane, out IntPtr glTexture);
|
||||
void* glCalculatorHelper, void* gpuBuffer, int plane, out void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__CreateDestinationTexture__i_i_ui(
|
||||
IntPtr glCalculatorHelper, int outputWidth, int outputHeight, GpuBufferFormat formatCode, out IntPtr glTexture);
|
||||
void* glCalculatorHelper, int outputWidth, int outputHeight, GpuBufferFormat formatCode, out void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__CreateDestinationTexture__Rgb(
|
||||
IntPtr glCalculatorHelper, IntPtr gpuBuffer, out IntPtr glTexture);
|
||||
void* glCalculatorHelper, void* gpuBuffer, out void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__BindFrameBuffer__Rtexture(IntPtr glCalculatorHelper, IntPtr glTexture);
|
||||
public static extern MpReturnCode mp_GlCalculatorHelper__BindFrameBuffer__Rtexture(void* glCalculatorHelper, void* glTexture);
|
||||
}
|
||||
}
|
||||
|
@ -2,59 +2,58 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#region GlContext
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGlContext__delete(IntPtr sharedGlContext);
|
||||
public static extern void mp_SharedGlContext__delete(void* sharedGlContext);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGlContext__reset(IntPtr sharedGlContext);
|
||||
public static extern void mp_SharedGlContext__reset(void* sharedGlContext);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlContext_GetCurrent(out IntPtr sharedGlContext);
|
||||
public static extern MpReturnCode mp_GlContext_GetCurrent(out void* sharedGlContext);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlContext_Create__P_b([MarshalAs(UnmanagedType.I1)] bool createThread, out IntPtr statusOrSharedGlContext);
|
||||
public static extern MpReturnCode mp_GlContext_Create__P_b(bool createThread, out void* statusOrSharedGlContext);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlContext_Create__Rgc_b(
|
||||
IntPtr shareContext, [MarshalAs(UnmanagedType.I1)] bool createThread, out IntPtr statusOrSharedGlContext);
|
||||
void* shareContext, bool createThread, out void* statusOrSharedGlContext);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlContext_Create__ui_b(
|
||||
uint shareContext, [MarshalAs(UnmanagedType.I1)] bool createThread, out IntPtr statusOrSharedGlContext);
|
||||
uint shareContext, bool createThread, out void* statusOrSharedGlContext);
|
||||
|
||||
[SupportedOSPlatform("IOS")]
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlContext_Create__Pes_b(
|
||||
IntPtr sharegroup, [MarshalAs(UnmanagedType.I1)] bool createThread, out IntPtr statusOrSharedGlContext);
|
||||
void* sharegroup, bool createThread, out void* statusOrSharedGlContext);
|
||||
#endregion
|
||||
|
||||
#region GlSyncToken
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_GlSyncToken__delete(IntPtr glSyncToken);
|
||||
public static extern void mp_GlSyncToken__delete(void* glSyncToken);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_GlSyncToken__reset(IntPtr glSyncToken);
|
||||
public static extern void mp_GlSyncToken__reset(void* glSyncToken);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlSyncPoint__Wait(IntPtr glSyncPoint);
|
||||
public static extern MpReturnCode mp_GlSyncPoint__Wait(void* glSyncPoint);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlSyncPoint__WaitOnGpu(IntPtr glSyncPoint);
|
||||
public static extern MpReturnCode mp_GlSyncPoint__WaitOnGpu(void* glSyncPoint);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlSyncPoint__IsReady(IntPtr glSyncPoint, out bool value);
|
||||
public static extern MpReturnCode mp_GlSyncPoint__IsReady(void* glSyncPoint, out bool value);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlSyncPoint__GetContext(IntPtr glSyncPoint, out IntPtr sharedGlContext);
|
||||
public static extern MpReturnCode mp_GlSyncPoint__GetContext(void* glSyncPoint, out void* sharedGlContext);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,22 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTexture__(out IntPtr glTexture);
|
||||
public static extern MpReturnCode mp_GlTexture__(out void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_GlTexture__delete(IntPtr glTexture);
|
||||
public static extern void mp_GlTexture__delete(void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTexture__Release(IntPtr glTexture);
|
||||
public static extern MpReturnCode mp_GlTexture__Release(void* glTexture);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTexture__GetGpuBufferFrame(IntPtr glTexture, out IntPtr gpuBuffer);
|
||||
public static extern MpReturnCode mp_GlTexture__GetGpuBufferFrame(void* glTexture, out void* gpuBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -2,49 +2,48 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
#region GlTextureBuffer
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitUntilComplete(IntPtr glTextureBuffer);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitUntilComplete(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitOnGpu(IntPtr glTextureBuffer);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitOnGpu(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__Reuse(IntPtr glTextureBuffer);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__Reuse(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__Updated__Pgst(IntPtr glTextureBuffer, IntPtr prodToken);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__Updated__Pgst(void* glTextureBuffer, void* prodToken);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__DidRead__Pgst(IntPtr glTextureBuffer, IntPtr consToken);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__DidRead__Pgst(void* glTextureBuffer, void* consToken);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitForConsumers(IntPtr glTextureBuffer);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitForConsumers(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitForConsumersOnGpu(IntPtr glTextureBuffer);
|
||||
public static extern MpReturnCode mp_GlTextureBuffer__WaitForConsumersOnGpu(void* glTextureBuffer);
|
||||
#endregion
|
||||
|
||||
#region SharedGlTextureBuffer
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGlTextureBuffer__delete(IntPtr glTextureBuffer);
|
||||
public static extern void mp_SharedGlTextureBuffer__delete(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGlTextureBuffer__reset(IntPtr glTextureBuffer);
|
||||
public static extern void mp_SharedGlTextureBuffer__reset(void* glTextureBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_SharedGlTextureBuffer__ui_ui_i_i_ui_PF_PSgc(
|
||||
uint target, uint name, int width, int height, GpuBufferFormat format,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] GlTextureBuffer.DeletionCallback deletionCallback,
|
||||
IntPtr producerContext, out IntPtr sharedGlTextureBuffer);
|
||||
GlTextureBuffer.DeletionCallback deletionCallback,
|
||||
void* producerContext, out void* sharedGlTextureBuffer);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,47 +2,46 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[SupportedOSPlatform("Linux"), SupportedOSPlatform("Android")]
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GpuBuffer__PSgtb(IntPtr glTextureBuffer, out IntPtr gpuBuffer);
|
||||
public static extern MpReturnCode mp_GpuBuffer__PSgtb(void* glTextureBuffer, out void* gpuBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_GpuBuffer__delete(IntPtr gpuBuffer);
|
||||
public static extern void mp_GpuBuffer__delete(void* gpuBuffer);
|
||||
|
||||
#region StatusOr
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_StatusOrGpuBuffer__delete(IntPtr statusOrGpuBuffer);
|
||||
public static extern void mp_StatusOrGpuBuffer__delete(void* statusOrGpuBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrGpuBuffer__status(IntPtr statusOrGpuBuffer, out IntPtr status);
|
||||
public static extern MpReturnCode mp_StatusOrGpuBuffer__status(void* statusOrGpuBuffer, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrGpuBuffer__value(IntPtr statusOrGpuBuffer, out IntPtr gpuBuffer);
|
||||
public static extern MpReturnCode mp_StatusOrGpuBuffer__value(void* statusOrGpuBuffer, out void* gpuBuffer);
|
||||
#endregion
|
||||
|
||||
#region Packet
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeGpuBufferPacket__Rgb(IntPtr gpuBuffer, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeGpuBufferPacket__Rgb(void* gpuBuffer, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeGpuBufferPacket_At__Rgb_Rts(IntPtr gpuBuffer, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeGpuBufferPacket_At__Rgb_Rts(void* gpuBuffer, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ConsumeGpuBuffer(IntPtr packet, out IntPtr statusOrGpuBuffer);
|
||||
public static extern MpReturnCode mp_Packet__ConsumeGpuBuffer(void* packet, out void* statusOrGpuBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetGpuBuffer(IntPtr packet, out IntPtr gpuBuffer);
|
||||
public static extern MpReturnCode mp_Packet__GetGpuBuffer(void* packet, out void* gpuBuffer);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsGpuBuffer(IntPtr packet, out IntPtr status);
|
||||
public static extern MpReturnCode mp_Packet__ValidateAsGpuBuffer(void* packet, out void* status);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using Mediapipe.Net.Gpu;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__GlTextureInfoForGpuBufferFormat__ui_i_ui(
|
||||
|
@ -2,32 +2,31 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGpuResources__delete(IntPtr gpuResources);
|
||||
public static extern void mp_SharedGpuResources__delete(void* gpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_SharedGpuResources__reset(IntPtr gpuResources);
|
||||
public static extern void mp_SharedGpuResources__reset(void* gpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GpuResources_Create(out IntPtr statusOrGpuResources);
|
||||
public static extern MpReturnCode mp_GpuResources_Create(out void* statusOrGpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_GpuResources_Create__Pv(IntPtr externalContext, out IntPtr statusOrGpuResources);
|
||||
public static extern MpReturnCode mp_GpuResources_Create__Pv(void* externalContext, out void* statusOrGpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_StatusOrGpuResources__delete(IntPtr statusOrGpuResources);
|
||||
public static extern void mp_StatusOrGpuResources__delete(void* statusOrGpuResources);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrGpuResources__status(IntPtr statusOrGpuResources, out IntPtr status);
|
||||
public static extern MpReturnCode mp_StatusOrGpuResources__status(void* statusOrGpuResources, out void* status);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_StatusOrGpuResources__value(IntPtr statusOrGpuResources, out IntPtr gpuResources);
|
||||
public static extern MpReturnCode mp_StatusOrGpuResources__value(void* statusOrGpuResources, out void* gpuResources);
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,23 @@
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mediapipe.Net.Graphs.InstantMotionTracking;
|
||||
|
||||
namespace Mediapipe.Net.Native
|
||||
{
|
||||
internal partial class UnsafeNativeMethods : NativeMethods
|
||||
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeAnchor3dVectorPacket__PA_i(Anchor3d[] value, int size, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeAnchor3dVectorPacket__PA_i(Anchor3d[] value, int size, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeAnchor3dVectorPacket_At__PA_i_Rt(Anchor3d[] value, int size, IntPtr timestamp, out IntPtr packet);
|
||||
public static extern MpReturnCode mp__MakeAnchor3dVectorPacket_At__PA_i_Rt(Anchor3d[] value, int size, void* timestamp, out void* packet);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_Anchor3dArray__delete(IntPtr anchorVectorData);
|
||||
public static extern void mp_Anchor3dArray__delete(void* anchorVectorData);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetAnchor3dVector(IntPtr packet, out Anchor3dVector anchorVector);
|
||||
public static extern MpReturnCode mp_Packet__GetAnchor3dVector(void* packet, out Anchor3dVector anchorVector);
|
||||
}
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ namespace Mediapipe.Net.Util
|
||||
/// <remarks>
|
||||
/// There must not be more than one instance at the same time.
|
||||
/// </remarks>
|
||||
public abstract class ResourceManager
|
||||
public unsafe abstract class ResourceManager
|
||||
{
|
||||
public delegate string PathResolver(string path);
|
||||
public abstract PathResolver ResolvePath { get; }
|
||||
public delegate bool ResourceProvider(string path, IntPtr output);
|
||||
public delegate bool ResourceProvider(string path, void* output);
|
||||
public abstract ResourceProvider ProvideResource { get; }
|
||||
|
||||
private static readonly object initLock = new object();
|
||||
|
30
Mediapipe.Net/Util/UnsafeUtil.cs
Normal file
30
Mediapipe.Net/Util/UnsafeUtil.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) homuler and Vignette
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
namespace Mediapipe.Net.Util
|
||||
{
|
||||
internal unsafe static class UnsafeUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Copies all objects from an unsafe array to a safe array.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer array of objects.</param>
|
||||
/// <param name="length">The number of elements inside of the unsafe array.</param>
|
||||
/// <typeparam name="T">The type of elements in the array.</typeparam>
|
||||
/// <remarks>
|
||||
/// It doesn't do any kind of deep copy of the elements.
|
||||
/// So if the object of type T contains references to other objects,
|
||||
/// the references will be copied and not the objects themselves.
|
||||
/// </remarks>
|
||||
/// <returns>A safe array containing a copy of the elements from the unsafe array.</returns>
|
||||
public static T[] SafeArrayCopy<T>(T* ptr, int length)
|
||||
where T : unmanaged
|
||||
{
|
||||
T[] array = new T[length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = ptr[i];
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user