Browse Source

Merge branch 'ZIM-DEV'

ZIM 1 year ago
parent
commit
1d6e1a4ac4

+ 1 - 11
Assets/InfraredProject/InfraredCamera/Scripts/ScreenLocate.cs

@@ -46,17 +46,7 @@ public partial class ScreenLocate : MonoBehaviour
 
             //screenIdentification?.SetScreenQuad(quad);
             screenIdentification.QuadManual = quad;
-            Debug.Log("<color=aqua>[ScreenLocate] 记录手动数据</color>");
-
-            //screenIdentification?.SetScreenQuad(
-            //    new QuadrilateralInCamera(
-            //        new o0.Geometry2D.Float.Vector(points[0].x * size.x, points[0].y * size.y),
-            //        new o0.Geometry2D.Float.Vector(points[1].x * size.x, points[1].y * size.y),
-            //        new o0.Geometry2D.Float.Vector(points[3].x * size.x, points[3].y * size.y),
-            //        new o0.Geometry2D.Float.Vector(points[2].x * size.x, points[2].y * size.y),
-            //        size.o0Vector()
-            //    )
-            //);
+            Debug.Log($"[ScreenLocate] 记录手动数据: {quad}");
         }
         ToMode(Mode.InfraredLocate);
     }

+ 4 - 1
Assets/InfraredProject/WebCamera/Script/ZIM/DebugOnDemo.cs

@@ -26,8 +26,11 @@ public class DebugOnDemo : MonoBehaviour
     {
         yield return null;
         ScreenLocate.Main.DebugOnZIMDemo = true;
+# if UNITY_ANDROID
+        ScreenLocate.Main.SaveToggle.isOn = false;
+#else
         ScreenLocate.Main.SaveToggle.isOn = true;
-
+#endif
         ScreenLocate.Main.FullScreenToggle.gameObject.SetActive(true);
         ScreenLocate.Main.FullScreenToggle.onValueChanged.AddListener((i) =>
         {

+ 12 - 12
Assets/InfraredProject/WebCamera/Script/ZIM/InfraredLocate/ScreenIdentification.cs

@@ -195,7 +195,7 @@ namespace o0.Project
             }
 
             //times.Add(watch.ElapsedMilliseconds);
-            //UnityEngine.Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
+            //Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
         }
 
         public void NextScreen()
@@ -318,8 +318,8 @@ namespace o0.Project
                 }
                 else if (quadTemp.Count == 1)
                 {
-                    Screen.QuadInCamera = quadTemp[0];
-                    Debug.Log($"<color=aqua>[ScreenIdentification] 拟合成功,识别数据: {Screen.QuadInCamera}</color>");
+                    SetScreenQuad(quadTemp[0]);
+                    Debug.Log($"[ScreenIdentification] 拟合成功,识别数据: {Screen.QuadInCamera}");
                 }
                 else
                 {
@@ -357,8 +357,8 @@ namespace o0.Project
                             predicts.Add(lr.Predict<Vector>(1));
                         }
                     }
-                    Screen.QuadInCamera = new QuadrilateralInCamera(predicts, new Vector(Size.x, Size.y));
-                    Debug.Log($"<color=aqua>[ScreenIdentification] 拟合成功,RSquared: {rs}, Quad: {Screen.QuadInCamera.QuadString}____{Screen.QuadInCamera.SizeString}</color>");
+                    SetScreenQuad(new QuadrilateralInCamera(predicts, new Vector(Size.x, Size.y)));
+                    Debug.Log($"[ScreenIdentification] 拟合成功,RSquared: {rs}, Quad: {Screen.QuadInCamera}");
                     //if (rs < 0.8) Screen.Quad = null;
                 }
 
@@ -563,7 +563,7 @@ namespace o0.Project
 
 
             times.Add(watch.ElapsedMilliseconds);
-            UnityEngine.Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
+            Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
 
             //ScreenLocate.DebugTexture(5, edge.IdentifyLine(edgeDir).ToTex());
             //ScreenLocate.DebugTexture(4, ScreenLocateTexLighted.Too0Mat().IdentifyEdgeGradientX().ToTex());
@@ -727,7 +727,7 @@ namespace o0.Project
             }
             Texture2D ScreenLocateTexture = LocateTexTemp[0];       // for output
 
-            // 如果有旧的手动数据,刷新一下Size
+            // 如果有手动数据,刷新一下Size
             QuadManual?.ReSize(new Vector(Size.x, Size.y), ScreenMap.ViewAspectRatioSetting);
             // 估算屏幕中点,如果已有手动定位数据,根据现有数据取平均即可,否则从色差计算,ScreenLocateMatList[0]默认是屏幕的黑白色差
             Vector AvgPoint = QuadManual != null ? QuadManual.Quad.Centroid : GetAvgPoint(ScreenLocateMatList[0]);
@@ -784,17 +784,17 @@ namespace o0.Project
             // 优先应用半自动的结果(也可以在外部手动设置)
             if (QuadSemiAuto == null && QuadAuto == null && Screen.QuadInCamera != null)     // 如果可能,回退到上一个screen
             {
-                Debug.Log("<color=aqua>[ScreenIdentification] 本次识别失败,回退到上次的识别结果</color>");
+                Debug.Log($"<color=yellow>[ScreenIdentification] 本次识别失败,回退到上次的识别结果: {Screen.QuadInCamera}</color>");
                 quadTemp.Add(Screen.QuadInCamera);
             }
             else if (QuadSemiAuto != null)
             {
-                Debug.Log("<color=aqua>[ScreenIdentification] 识别到四边形</color>");
+                Debug.Log($"<color=aqua>[ScreenIdentification] 识别到四边形(半自动): {QuadSemiAuto}</color>");
                 quadTemp.Add(QuadSemiAuto);
             }
             else if (QuadAuto != null)
             {
-                Debug.Log("<color=aqua>[ScreenIdentification] 识别到四边形</color>");
+                Debug.Log($"<color=aqua>[ScreenIdentification] 识别到四边形(全自动): {QuadAuto}</color>");
                 quadTemp.Add(QuadAuto);
             }
 
@@ -856,7 +856,7 @@ namespace o0.Project
             }
 
             //times.Add(watch.ElapsedMilliseconds);
-            //UnityEngine.Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
+            //Debug.Log("time: " + (times[times.Count - 1] - times[times.Count - 2]));
 
             // opecncv处理, zim
             {
@@ -1005,7 +1005,7 @@ namespace o0.Project
             manualLines = null;
             if (QuadManual != null)
             {
-                Debug.Log("[IdentifyLineLSD] 根据已有定位数据做筛选");
+                Debug.Log($"[IdentifyLineLSD] 根据已有定位数据做筛选, QuadManual: {QuadManual}");
                 manualLines = QuadManual.GetLines().Select((i) => new LineIdentified(0, i, 0, 0, true)).ToArray();
                 var calibration = ScreenLocate.Main.ReDoLocateCalibrationRatio * Size.y;
                 var avgPointCross = manualLines.Select((i) => i.Line.LineCrossWithPoint(avgPoint)).ToArray();     // 对于平均点的corss值

+ 1 - 1
Assets/InfraredProject/WebCamera/Script/ZIM/InfraredLocate/ScreenMap.cs

@@ -39,7 +39,7 @@ namespace ZIM.Unity
         {
             if (QuadInCamera != null && QuadInCamera.CameraSize != sizeNew)
             {
-                UnityEngine.Debug.Log("[ScreenMap]根据分辨率映射: from " + QuadInCamera.SizeString + " to " + sizeNew);
+                Debug.Log($"[ScreenMap]根据分辨率映射: from {QuadInCamera.SizeString} to ({sizeNew.x}, {sizeNew.y})");
                 QuadInCamera.ReSize(sizeNew, ViewAspectRatioSetting);
                 InitByQuad();
                 return true;

+ 4 - 2
Assets/InfraredProject/WebCamera/Script/ZIM/ScreenLocate.cs

@@ -437,7 +437,7 @@ public partial class ScreenLocate : MonoBehaviour
             screenIdentification = new o0.Project.ScreenIdentification();
 
             Debug.Log("[ScreenLocate] 初始化屏幕识别");
-            screenIdentification.OnLocateScreenEnter += OnLocateScreenEnter;
+            //screenIdentification.OnLocateScreenEnter += OnLocateScreenEnter;
             screenIdentification.OnLocateScreenEnd += OnLocateScreenEnd;
         }
         if (infraredLocate == null)
@@ -804,7 +804,7 @@ public partial class ScreenLocate : MonoBehaviour
         //Debug.Log("BtnScreenLocate Capture:" + Capture + " ,Delay: " + Delay);
         //screenIdentification.LocateScreen(Capture, Delay);
 
-        screenIdentification.LocateScreen();        // 自动识别开始的入口
+        OnLocateScreenEnter();
     }
     // bool log1 = false, log2 = false;
     public void OnLocateScreenEnter()
@@ -824,6 +824,8 @@ public partial class ScreenLocate : MonoBehaviour
         // log1 = true;
         // log2 = true;
 
+        screenIdentification.LocateScreen();        // 自动识别开始的入口
+
         if (DebugOnZIMDemo)
         {
             var webCam = GetComponent<ZIMWebCamera>();

+ 0 - 12
Assets/SmartBow/Scripts/Views/InfraredViewParts/InfraredScreenPositioningView.cs

@@ -869,18 +869,6 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
                 2 * (targetList[1] + lo),
                 2 * (targetList[2] + lo),
                 2 * (targetList[3] + lo) };
-
-        // 记录手动数据
-        //var size = ScreenLocate.Main.getUVCCameraInfoSize;
-        //var quad = new QuadrilateralInCamera(
-        //        new o0.Geometry2D.Float.Vector(targetList[0].x * size.x, targetList[0].y * size.y),
-        //        new o0.Geometry2D.Float.Vector(targetList[1].x * size.x, targetList[1].y * size.y),
-        //        new o0.Geometry2D.Float.Vector(targetList[3].x * size.x, targetList[3].y * size.y),
-        //        new o0.Geometry2D.Float.Vector(targetList[2].x * size.x, targetList[2].y * size.y),
-        //        size.o0Vector()
-        //    );
-        //ScreenLocate.Main.ScreenIdentification.QuadManual = quad;
-        //Debug.Log("<color=aqua>[ScreenLocate] 记录手动数据</color>");
     }
 
     void SaveLocalPos()