Browse Source

Merge branch 'ZIM-DEV'

ZIM 10 months ago
parent
commit
46d9d94644

+ 38 - 24
Assets/InfraredProject/WebCamera/Script/ZIM/ScreenLocate.cs

@@ -148,6 +148,7 @@ public partial class ScreenLocate : o0InfraredCameraHandler
     public RectTransform ScreenQuad;
     public Toggle SaveToggle;
     public Toggle FullScreenToggle;
+    public Toggle SingleToggle;
     public LineGenerator UILineGenerator;
 
     public bool ShowScreenQuad = false;
@@ -356,6 +357,41 @@ public partial class ScreenLocate : o0InfraredCameraHandler
         #endregion
     }
 
+    // 初始化算法
+    void AlgorithmInit()
+    {
+        if (screenIdentification == null)
+        {
+            screenIdentification = new o0.Project.ScreenIdentification(this);
+
+            Debug.Log("[ScreenLocate] 初始化屏幕识别");
+            //screenIdentification.OnLocateScreenEnter += OnLocateScreenEnter;
+            screenIdentification.OnLocateScreenEnd += OnLocateScreenEnd;
+
+            //初始化屏幕数据
+            InfraredCameraHelper.InitScreenLocateManual();
+        }
+        if (infraredLocate == null)
+        {
+            infraredLocate = new InfraredLocate(this, screenIdentification.Screen);
+            cameraSize = new Vector(getUVCCameraInfoSize.x, getUVCCameraInfoSize.y);
+            InfraredSpot.RefreshMinVerifyLength(new o0.Geometry2D.Float.Vector(getUVCCameraInfoSize.x, getUVCCameraInfoSize.y));
+
+            Debug.Log($"[ScreenLocate] 初始化红外灯识别, 当前相机分辨率: {CameraSize.x}×{CameraSize.y},红外算法追踪距离: {InfraredSpot.MinVerifyLength}");
+            //InfraredDemo 初始化
+            //float redfilterValue = PlayerPrefs.GetFloat("Init redFilterSliderValue", 0.8f);
+            //Debug.Log("Init Red filterValue:" + redfilterValue);
+            //infraredLocate.SetBrightnessThreshold(redfilterValue);     // 参数是 红外灯的亮度阈值,阈值越小能够检测到的亮度就越低,默认值是0.93
+
+            // UI相关
+            infraredLocate.SetSinglePoint(SingleToggle.isOn);
+            SingleToggle.onValueChanged.AddListener((i) =>
+            {
+                infraredLocate.SetSinglePoint(i);
+            });
+        }
+    }
+
     IEnumerator LateDestoryIEnum(UnityEngine.Object o)
     {
         if (o)
@@ -451,29 +487,7 @@ public partial class ScreenLocate : o0InfraredCameraHandler
 
         if (mUVCCameraInfo == null) return;
 
-        if (screenIdentification == null)
-        {
-            screenIdentification = new o0.Project.ScreenIdentification(this);
-
-            Debug.Log("[ScreenLocate] 初始化屏幕识别");
-            //screenIdentification.OnLocateScreenEnter += OnLocateScreenEnter;
-            screenIdentification.OnLocateScreenEnd += OnLocateScreenEnd;
-
-            //初始化屏幕数据
-            InfraredCameraHelper.InitScreenLocateManual();
-        }
-        if (infraredLocate == null)
-        {
-            infraredLocate = new InfraredLocate(this, screenIdentification.Screen);
-            cameraSize = new Vector(getUVCCameraInfoSize.x, getUVCCameraInfoSize.y);
-            InfraredSpot.RefreshMinVerifyLength(new o0.Geometry2D.Float.Vector(getUVCCameraInfoSize.x, getUVCCameraInfoSize.y));
-
-            Debug.Log($"[ScreenLocate] 初始化红外灯识别, 当前相机分辨率: {CameraSize.x}×{CameraSize.y},红外算法追踪距离: {InfraredSpot.MinVerifyLength}");
-            //InfraredDemo 初始化
-            //float redfilterValue = PlayerPrefs.GetFloat("Init redFilterSliderValue", 0.8f);
-            //Debug.Log("Init Red filterValue:" + redfilterValue);
-            //infraredLocate.SetBrightnessThreshold(redfilterValue);     // 参数是 红外灯的亮度阈值,阈值越小能够检测到的亮度就越低,默认值是0.93
-        }
+        AlgorithmInit();
 
         /* New*/
         //Debug.Log((mUVCCameraInfo != null) +" = "+ mUVCCameraInfo.IsPreviewing + " = "+ screenIdentification.Screen.Active);
@@ -806,7 +820,7 @@ public partial class ScreenLocate : o0InfraredCameraHandler
         if (Vector2.Distance(np, _targetPoints2[index]) >= filterDis)
         {
             _targetPoints2[index] = np;
-            InfraredCameraHelper.InvokeOnPositionUpdate2(_targetPoints2[index], index);
+            InfraredCameraHelper?.InvokeOnPositionUpdate2(_targetPoints2[index], index);
         }
     }
 

File diff suppressed because it is too large
+ 355 - 30
Assets/InfraredProject/WebCamera/zimWebCamera.unity


BIN
Assets/Plugins/o0InfraredLocate/o0InfraredLocate.dll


Some files were not shown because too many files changed in this diff