mirror of
https://github.com/cosyneco/MediaPipe.NET.git
synced 2025-08-24 08:40:39 +08:00
Port InstantMotionTracking
This commit is contained in:
22
Mediapipe.Net/Graphs/InstantMotionTracking/Anchor3d.cs
Normal file
22
Mediapipe.Net/Graphs/InstantMotionTracking/Anchor3d.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) homuler and Vignette
|
||||
// This file is part of MediaPipe.NET.
|
||||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mediapipe.Net.Graphs.InstantMotionTracking
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Anchor3d
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public int StickerId;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({X}, {Y}, {Z}), #{StickerId}";
|
||||
}
|
||||
}
|
||||
}
|
35
Mediapipe.Net/Graphs/InstantMotionTracking/Anchor3dVector.cs
Normal file
35
Mediapipe.Net/Graphs/InstantMotionTracking/Anchor3dVector.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) homuler and Vignette
|
||||
// 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 Mediapipe.Net.Native;
|
||||
|
||||
namespace Mediapipe.Net.Graphs.InstantMotionTracking
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct Anchor3dVector
|
||||
{
|
||||
public IntPtr Data;
|
||||
public int Size;
|
||||
|
||||
public void Dispose() => UnsafeNativeMethods.mp_Anchor3dArray__delete(Data);
|
||||
|
||||
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++));
|
||||
}
|
||||
|
||||
return anchors;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// Copyright (c) homuler and Vignette
|
||||
// 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
|
||||
{
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp__MakeAnchor3dVectorPacket__PA_i(Anchor3d[] value, int size, out IntPtr 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);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern void mp_Anchor3dArray__delete(IntPtr anchorVectorData);
|
||||
|
||||
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
||||
public static extern MpReturnCode mp_Packet__GetAnchor3dVector(IntPtr packet, out Anchor3dVector anchorVector);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user