12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
-
- namespace NRKernal
- {
- using AOT;
- using System;
- using UnityEngine;
-
- internal class NRRgbCamera : NativeCameraProxy
- {
-
- public new static string ID = "NRRgbCamera";
-
-
- public override NativeResolution Resolution
- {
- get
- {
- #if !UNITY_EDITOR
- NativeResolution resolution = NRFrame.GetDeviceResolution(NativeDevice.RGB_CAMERA);
- #else
- NativeResolution resolution = new NativeResolution(1280, 720);
- #endif
- return resolution;
- }
- }
- #if !UNITY_EDITOR
- public NRRgbCamera() : base(new NativeCamera()) { }
- #else
-
- public NRRgbCamera() : base(new EditorCameraDataProvider()) { }
- #endif
-
- public override void Initialize()
- {
- base.Initialize();
- RegistCaptureCallback(RGBCameraCapture);
- }
-
-
-
-
-
-
- [MonoPInvokeCallback(typeof(CameraImageCallback))]
- public static void RGBCameraCapture(UInt64 camera_handle, UInt64 camera_image_handle, UInt64 userdata)
- {
- var controller = CameraProxyFactory.GetInstance(NRRgbCamera.ID);
- if (controller == null)
- {
- NRDebugger.Error("[NRRgbCamera] get controller instance faild.");
- return;
- }
- controller.UpdateFrame(camera_handle, camera_image_handle, userdata);
- }
-
-
-
-
- public override void UpdateFrame(UInt64 camera_handle, UInt64 camera_image_handle, UInt64 userdata)
- {
- int RawDataSize = 0;
- this.CameraDataProvider.GetRawData(camera_image_handle, (int)NativeDevice.RGB_CAMERA, ref this.m_TexturePtr, ref RawDataSize);
- var timestamp = this.CameraDataProvider.GetHMDTimeNanos(camera_image_handle, (int)NativeDevice.RGB_CAMERA);
- this.QueueFrame(this.m_TexturePtr, RawDataSize, timestamp);
- this.CameraDataProvider.DestroyImage(camera_image_handle);
- }
- }
- }
|