/****************************************************************************
* Copyright 2019 Nreal Techonology Limited. All rights reserved.
*
* This file is part of NRSDK.
*
* https://www.nreal.ai/
*
*****************************************************************************/
namespace NRKernal
{
using System;
using System.Runtime.InteropServices;
using UnityEngine;
public enum TextureType
{
RGB,
YUV
}
/// A camera texture frame.
public struct CameraTextureFrame
{
/// The time stamp.
public UInt64 timeStamp;
/// The gain
public UInt32 gain;
/// The exposureTime
public UInt32 exposureTime;
/// The texture.
public Texture texture;
}
public struct UniversalTextureFrame
{
public TextureType textureType;
/// The time stamp.
public UInt64 timeStamp;
/// The gain
public UInt32 gain;
/// The exposureTime
public UInt32 exposureTime;
/// The textures.
public Texture[] textures;
}
/// A frame raw data.
public partial struct FrameRawData
{
/// The time stamp.
public UInt64 timeStamp;
/// The gain
public UInt32 gain;
/// The exposureTime
public UInt32 exposureTime;
/// The data.
public byte[] data;
public IntPtr nativeTexturePtr;
/// Makes a safe.
/// The textureptr.
/// The size.
/// The timestamp.
/// [in,out] The frame.
/// True if it succeeds, false if it fails.
public static bool MakeSafe(IntPtr textureptr, int size, UInt64 timestamp, ref FrameRawData frame)
{
if (textureptr == IntPtr.Zero || size <= 0)
{
return false;
}
if (frame.data == null || frame.data.Length != size)
{
frame.data = new byte[size];
}
frame.timeStamp = timestamp;
frame.gain = 0;
frame.exposureTime = 0;
frame.nativeTexturePtr = textureptr;
Marshal.Copy(textureptr, frame.data, 0, size);
return true;
}
/// Convert this object into a string representation.
/// A string that represents this object.
public override string ToString()
{
return string.Format("timestamp :{0} data size:{1}", timeStamp, data.Length);
}
}
}