Bladeren bron

更新infraredSpot追踪逻辑

ZIM 1 jaar geleden
bovenliggende
commit
75943d6d3a

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

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 using ZIM.Unity;
 using Color = UnityEngine.Color;
@@ -85,12 +86,13 @@ namespace ZIM
             PixelSpotArea select = null;
             var minLength = float.MaxValue;
             var predict = Predict.Value;
+            var refPoint = (predict + spots.Last().Centroid) / 2;       // 用预测点和最后一个点的中点来判断是否追踪到
             foreach (var i in areas)
             {
-                var len = (i.Centroid - predict).magnitude;
+                var len = (i.Centroid - refPoint).magnitude;
                 if (len < MinVerifyLength)
                 {
-                    if (len < minLength)
+                    if (len < minLength)        // 找到追踪到的,并且距离最近的spot
                     {
                         select = i;
                         minLength = len;