Browse Source

1.添加可调整阈值ui

slambb 1 year ago
parent
commit
25e4dfad02

+ 26 - 0
Assets/InfraredCamera/Scripts/SettingPanel.cs

@@ -15,6 +15,10 @@ public class SettingPanel : MonoBehaviour
     public Text sliderText;
     public Slider filterSlider;
 
+
+    public Text redSliderText;
+    public Slider redFilterSlider;
+
     int selectIndex = 0;
     //void Awake()
     //{
@@ -31,6 +35,13 @@ public class SettingPanel : MonoBehaviour
         filterSlider.value = filterValue;
         setSliderText(filterValue);
         filterSlider.onValueChanged.AddListener(setFilterSliderValue);
+
+
+        float redfilterValue = PlayerPrefs.GetFloat("redFilterSliderValue", 0.8f);
+        Debug.Log("red filterValue:" + redfilterValue);
+        redFilterSlider.value = redfilterValue;
+        setRedSliderText(redfilterValue);
+        redFilterSlider.onValueChanged.AddListener(setRedFilterSliderValue);
     }
     void Start()
     {
@@ -139,4 +150,19 @@ public class SettingPanel : MonoBehaviour
         sliderText.text = value + "";
         Debug.Log("当前过滤阈值 filter dis:"+ ScreenLocate.Main.filterDis);
     }
+
+    public void setRedFilterSliderValue(float value)
+    {
+        Debug.Log("red滑动进度条:" + value);
+        setRedSliderText(value);
+        PlayerPrefs.SetFloat("redFilterSliderValue", value);
+        PlayerPrefs.Save();
+    }
+
+    void setRedSliderText(float value)
+    {
+        ScreenLocate.Main.SetInfraredLocateBrightnessThreshold(value);
+        redSliderText.text = value + "";
+        Debug.Log("当前红外线阈值 BrightnessThreshold:" + value);
+    }
 }

File diff suppressed because it is too large
+ 477 - 304
Assets/Resources/WebCameraView.prefab


+ 11 - 1
Assets/WebCamera/Script/ZIM/ScreenLocate.cs

@@ -290,6 +290,14 @@ public class ScreenLocate : MonoBehaviour
     //    brightnessText.text = (2 + brightness) + "";
     //}
 
+    public void SetInfraredLocateBrightnessThreshold(float value) {
+
+        if (infraredLocate != null)
+        {
+            if(value>=0 && value <=1)
+                infraredLocate.SetBrightnessThreshold(value);     // 参数是 红外灯的亮度阈值,阈值越小能够检测到的亮度就越低,默认值是0.93
+        }
+    }
 
     void Update()
     {
@@ -314,7 +322,9 @@ public class ScreenLocate : MonoBehaviour
         if (infraredLocate == null)
         {
             infraredLocate = new InfraredLocate(mUVCCameraInfo, screenIdentification, InfraredSpotSettings);
-            infraredLocate.SetBrightnessThreshold(0.8f);     // 参数是 红外灯的亮度阈值,阈值越小能够检测到的亮度就越低,默认值是0.93
+            float redfilterValue = PlayerPrefs.GetFloat("Init redFilterSliderValue", 0.8f);
+            Debug.Log("Init Red filterValue:" + redfilterValue);
+            infraredLocate.SetBrightnessThreshold(redfilterValue);     // 参数是 红外灯的亮度阈值,阈值越小能够检测到的亮度就越低,默认值是0.93
         }
 
         if (mode == Mode.ScreenLocateManual)

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