Просмотр исходного кода

红外定位页面实时画面

lvjincheng 2 лет назад
Родитель
Сommit
ca0aa2ec5c

+ 9 - 9
Assets/BowArrow/Modules/InfraredGuider/InfraredLightGuider.cs

@@ -1,15 +1,15 @@
-using InfraredManager;
+锘縰sing InfraredManager;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
-//处理光源检测部分
+//澶勭悊鍏夋簮妫€娴嬮儴鍒�
 public class InfraredLightGuider : MonoBehaviour
 {
     [SerializeField]
     RawImage rawImage;
-    //相机感光部分
+    //鐩告満鎰熷厜閮ㄥ垎
     [SerializeField]
     Slider slider;
     // Start is called before the first frame update
@@ -23,18 +23,18 @@ public class InfraredLightGuider : MonoBehaviour
             });
             InfraredDemo._ins.onSetSliderValue(slider);
         }
+    }
+
+    void Update()
+    {
         if (InfraredDemo.running)
         {
+            //娓叉煋鐩告満鐢婚潰
             rawImage.texture = InfraredDemo.infraredCameraHelper.GetCameraTexture();
+            rawImage.material = InfraredDemo.infraredCameraHelper.GetCameraMaterial();
         }
     }
 
-    // Update is called once per frame
-    //void Update()
-    //{
-        
-    //}
-
     public void Close() {
         Destroy(gameObject);
     }

+ 22 - 18
Assets/SmartBow/Scripts/Views/InfraredViewParts/InfraredScreenPositioningView.cs

@@ -61,18 +61,14 @@ public class InfraredScreenPositioningView  : JCUnityLib.ViewBase
         //    InfraredDemo._ins.SetBrightness(value);
         //});
         //slider.value = InfraredDemo._ins.brightness.Get();
+    }
 
-        //图像
+    void Update()
+    {
         if (InfraredDemo.running)
         {
-            //渲染截图
-            Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
-            if (texture2D == null)
-            {
-                InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
-                return;
-            }
-            rawImage.texture = texture2D;
+            //渲染相机画面
+            rawImage.texture = InfraredDemo.infraredCameraHelper.GetCameraTexture();
             rawImage.material = InfraredDemo.infraredCameraHelper.GetCameraMaterial();
         }
     }
@@ -176,7 +172,7 @@ public class InfraredScreenPositioningView  : JCUnityLib.ViewBase
     //确认修改
     public void onConfirmation()
     {
-
+        if (!ConfirmScreenLocateManual()) return;
 
         if (oldLinePosition.Count > 1) // 确保列表不为空
         {
@@ -191,10 +187,6 @@ public class InfraredScreenPositioningView  : JCUnityLib.ViewBase
             ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
             ViewManager2.ShowView(ViewManager2.Path_ConnectGuidanceView);
         }
-  
-
-
-        Quit();
 
         //存储一次节点
         SaveLocalPos();
@@ -225,21 +217,33 @@ public class InfraredScreenPositioningView  : JCUnityLib.ViewBase
     void RecordLocatePoint(RectTransform p, Vector2 pivot)
     {
         Vector2 pos = JCUnityLib.RectTransformUtils.GetPositionByPivot(p, pivot);
-        pos.x = pos.x / Screen.width * _texWidth;
-        pos.y = pos.y / Screen.height * _texHeight;
+        pos.x = Mathf.Clamp01(pos.x / Screen.width) * _texWidth;
+        pos.y = Mathf.Clamp01(pos.y / Screen.height) * _texHeight;
         _locatePointList.Add(pos);
     }
-    void Quit()
+    bool ConfirmScreenLocateManual()
     {
-        if (InfraredDemo.running && InfraredDemo.infraredCameraHelper.IsScreenLocateManualDoing())
+        if (InfraredDemo.running)
         {
+            //渲染截图
+            Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
+            if (texture2D == null)
+            {
+                InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
+                return false;
+            }
+            _locatePointList.Clear();
+            _texWidth = texture2D.width;
+            _texHeight = texture2D.height;
             RecordLocatePoint(pos1, new Vector2(0, 0));
             RecordLocatePoint(pos2, new Vector2(1, 0));
             RecordLocatePoint(pos3, new Vector2(1, 1));
             RecordLocatePoint(pos4, new Vector2(0, 1));
             InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(_locatePointList);
             FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, _texWidth, _texHeight);
+            return true;
         }
+        return false;
     }