Files
Ayase Minori baf3fbd8ea Fix CLR objects not being set as ptr owner (#55)
Signed-off-by: Ayane Satomi <ayane@vignetteapp.org>
2023-04-16 07:30:02 +08:00

40 lines
1.2 KiB
C#

// Copyright (c) homuler and The Vignette Authors
// This file is part of MediaPipe.NET.
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
using System;
using Mediapipe.Net.Framework.Port;
using Mediapipe.Net.Framework.Protobuf;
using Mediapipe.Net.Native;
namespace Mediapipe.Net.Framework.Packets
{
public class DetectionPacket : Packet<Detection>
{
public DetectionPacket() : base(true) { }
public DetectionPacket(IntPtr ptr, bool isOwner = true) : base(ptr, isOwner) { }
public DetectionPacket? At(Timestamp timestamp) => At<DetectionPacket>(timestamp);
public override Detection Get()
{
UnsafeNativeMethods.mp_Packet__GetDetection(MpPtr, out var serializedProtoVectorPtr).Assert();
GC.KeepAlive(this);
var detection = serializedProtoVectorPtr.Deserialize(Detection.Parser);
serializedProtoVectorPtr.Dispose();
return detection;
}
public override StatusOr<Detection> Consume()
{
throw new NotSupportedException();
}
public override Status ValidateAsType()
{
throw new NotSupportedException();
}
}
}