CameraProxyFactory.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using System.Collections.Generic;
  12. /// <summary> A camera proxy factory. </summary>
  13. public class CameraProxyFactory
  14. {
  15. /// <summary> Dictionary of camera controllers. </summary>
  16. private static Dictionary<string, NativeCameraProxy> m_CameraControllerDict = new Dictionary<string, NativeCameraProxy>();
  17. /// <summary> Creates RGB camera proxy. </summary>
  18. /// <returns> The new RGB camera proxy. </returns>
  19. public static NativeCameraProxy CreateRGBCameraProxy()
  20. {
  21. NativeCameraProxy controller;
  22. if (!m_CameraControllerDict.TryGetValue(NRRgbCamera.ID, out controller))
  23. {
  24. controller = new NRRgbCamera();
  25. m_CameraControllerDict.Add(NRRgbCamera.ID, controller);
  26. }
  27. return controller;
  28. }
  29. /// <summary> Gets an instance. </summary>
  30. /// <param name="id"> The identifier.</param>
  31. /// <returns> The instance. </returns>
  32. public static NativeCameraProxy GetInstance(string id)
  33. {
  34. if (!m_CameraControllerDict.ContainsKey(id))
  35. {
  36. return null;
  37. }
  38. return m_CameraControllerDict[id];
  39. }
  40. /// <summary> Regist camera proxy. </summary>
  41. /// <param name="id"> The identifier.</param>
  42. /// <param name="proxy"> The proxy.</param>
  43. public static void RegistCameraProxy(string id, NativeCameraProxy proxy)
  44. {
  45. m_CameraControllerDict[id] = proxy;
  46. }
  47. }
  48. }