ScreenLocate.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Serenegiant.UVC;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. using ZIM;
  7. using ZIM.Unity;
  8. /// <summary>
  9. /// JC-补充接口
  10. /// </summary>
  11. public partial class ScreenLocate : MonoBehaviour
  12. {
  13. public bool IsScreenLoateOK()
  14. {
  15. return screenIdentification != null &&
  16. screenIdentification.Screen != null &&
  17. screenIdentification.Screen.Active;
  18. }
  19. public bool IsScreenLocateManualDoing()
  20. {
  21. return mode == Mode.ScreenLocateManual;
  22. }
  23. public Texture2D EnterScreenLocateManual()
  24. {
  25. CreateUVCTexture2DIfNeeded();
  26. Texture2D texture = mUVCTexture2D.zimAutoLight(0);
  27. mode = Mode.ScreenLocateManual;
  28. return texture;
  29. }
  30. /// <summary>
  31. /// 屏幕定位时候的实际点转换成算法里面的点
  32. /// 左下、右下、右上、左上 => 左下,右下,左上,右上 (算法)
  33. /// </summary>
  34. /// <param name="points"></param>
  35. public void QuitScreenLocateManual(List<Vector2> points)
  36. {
  37. if (points != null && points.Count == 4)
  38. {
  39. var size = getUVCCameraInfoSize;
  40. screenIdentification?.SetScreenQuad(
  41. new QuadrilateralInCamera(
  42. new o0.Geometry2D.Float.Vector(points[0].x * size.x, points[0].y * size.y),
  43. new o0.Geometry2D.Float.Vector(points[1].x * size.x, points[1].y * size.y),
  44. new o0.Geometry2D.Float.Vector(points[3].x * size.x, points[3].y * size.y),
  45. new o0.Geometry2D.Float.Vector(points[2].x * size.x, points[2].y * size.y),
  46. size.o0Vector()
  47. )
  48. );
  49. }
  50. ToMode(Mode.InfraredLocate);
  51. }
  52. /// <summary>
  53. /// 传入算法对应的点来设置算法屏幕四边形
  54. /// </summary>
  55. /// <param name="points"></param>
  56. public void QuadUnityVectorListToScreenQuad(List<Vector2> points)
  57. {
  58. if (points != null && points.Count == 4)
  59. {
  60. var size = getUVCCameraInfoSize;
  61. screenIdentification?.SetScreenQuad(
  62. new QuadrilateralInCamera(
  63. new o0.Geometry2D.Float.Vector(points[0].x * size.x, points[0].y * size.y),
  64. new o0.Geometry2D.Float.Vector(points[1].x * size.x, points[1].y * size.y),
  65. new o0.Geometry2D.Float.Vector(points[2].x * size.x, points[2].y * size.y),
  66. new o0.Geometry2D.Float.Vector(points[3].x * size.x, points[3].y * size.y),
  67. size.o0Vector()
  68. )
  69. );
  70. }
  71. ToMode(Mode.InfraredLocate);
  72. }
  73. public void EnterScreenLocateManualAuto()
  74. {
  75. BtnScreenLocate();
  76. }
  77. public void SetCapture(int value)
  78. {
  79. Capture = value;
  80. }
  81. public void SetDelay(int value)
  82. {
  83. Delay = value;
  84. }
  85. }