18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
36 private Dictionary<GlassesHandle, CameraImageCore>
cameraImageCores =
new Dictionary<GlassesHandle, CameraImageCore>();
38 #region Public Functions
40 internal static void Initialize(GlassesHandle glassesHandle)
45 internal static void RemoveCore(GlassesHandle glassesHandle){
46 if(!
Instance.cameraImageCores.TryGetValue(glassesHandle, out var cameraImageCore)) {
return; }
47 cameraImageCore.Dispose();
48 Instance.cameraImageCores.Remove(glassesHandle);
60 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
75 return cameraImageCore.TryGetFilledCameraImageBuffer(ref camImage);
89 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
104 return cameraImageCore.TrySubmitEmptyCameraImageBuffer(imageBuffer, bufferSize);
118 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
133 return cameraImageCore.TryCancelCameraImageBuffer(imageBuffer);
144 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
159 return cameraImageCore.TryConfigureCameraImageStream(config);
162 #endregion Public Functions
174 this.glassesHandle = glassesId;
178 Log.
Info($
"CameraImageCore for {glassesHandle} disconnected");
189 catch (System.Exception e)
191 Log.
Error($
"Error enabling Camera Stream: {e.Message}");
204 catch (System.Exception e)
206 Log.
Error($
"Error getting Camera Image: {e.Message}");
218 catch (System.Exception e)
220 Log.
Error($
"Error submitting Camera Image Buffer: {e.Message}");
231 GCHandle handle = GCHandle.Alloc(imageBuffer, GCHandleType.Pinned);
232 var ImageBufferHandle = handle.AddrOfPinnedObject();
236 catch (System.Exception e)
238 Log.
Error($
"Error clearing Camera Image Buffers: {e.Message}");
Internal Camera Image core.
bool TryGetFilledCameraImageBuffer(ref T5_CamImage camImage)
CameraImageCore(GlassesHandle glassesId)
bool TryConfigureCameraImageStream(T5_CameraStreamConfig config)
bool TrySubmitEmptyCameraImageBuffer(IntPtr imageBuffer, UInt32 bufferSize)
bool TryCancelCameraImageBuffer(byte[] imageBuffer)
GlassesHandle glassesHandle
The Camera Frame API and runtime.
static bool TrySubmitEmptyCameraImageBuffer(PlayerIndex playerIndex, IntPtr imageBuffer, UInt32 bufferSize)
Submit a camera image buffer to be used by the camera image stream. As images become available the bu...
static bool TryCancelCameraImageBuffer(PlayerIndex playerIndex, byte[] imageBuffer)
Specify an image buffer to be released from the Tilt Five Service. If true is returned,...
Dictionary< GlassesHandle, CameraImageCore > cameraImageCores
The glasses core runtimes.
static bool TryConfigureCameraImageStream(PlayerIndex playerIndex, T5_CameraStreamConfig config)
Attempt to configure the Camera Stream
static bool TryGetFilledCameraImageBuffer(PlayerIndex playerIndex, ref T5_CamImage camImage)
Attempt to request a new filled buffer from the camera image stream. If an empty buffer has been subm...
The Glasses API and runtime.
static bool IsConnected(PlayerIndex playerIndex=PlayerIndex.One)
Indicate if the specified glasses are connected.
static void Info(string m, params object[] list)
INFO logging function call.
static void Error(string m, params object[] list)
ERROR logging function call.
Provides access to player settings and functionality.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)
Represents a wrapper on a buffer comtaining a camera image.
Camera Stream Configuration.