|
|
@@ -4,17 +4,26 @@ using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
|
using InfraredManager;
|
|
|
using ZIM;
|
|
|
+using System.Linq;
|
|
|
+using Serenegiant.UVC;
|
|
|
+using System;
|
|
|
|
|
|
public class InfraredDemo : MonoBehaviour
|
|
|
{
|
|
|
public static bool DebugInEditor = true;
|
|
|
public static InfraredDemo _ins;
|
|
|
+
|
|
|
+ [SerializeField]
|
|
|
+ RectTransform canvasRectTransform;
|
|
|
public static void Create()
|
|
|
{
|
|
|
if (_ins) return;
|
|
|
GameObject o = Instantiate(Resources.Load<GameObject>("InfraredDemo"));
|
|
|
DontDestroyOnLoad(o);
|
|
|
_ins = o.GetComponent<InfraredDemo>();
|
|
|
+
|
|
|
+ //直接初始化一次
|
|
|
+ _ins.InitInfraredCamera();
|
|
|
}
|
|
|
|
|
|
void Start()
|
|
|
@@ -26,6 +35,8 @@ public class InfraredDemo : MonoBehaviour
|
|
|
|
|
|
//直接初始化一次
|
|
|
InitInfraredCamera();
|
|
|
+ //如果本地有记录,初始化一次
|
|
|
+ initScreenLocateManual();
|
|
|
}
|
|
|
|
|
|
void Update()
|
|
|
@@ -46,7 +57,7 @@ public class InfraredDemo : MonoBehaviour
|
|
|
transform.Find("Background").gameObject.SetActive(value);
|
|
|
transform.Find("InfraredCamera").gameObject.SetActive(value);
|
|
|
transform.Find("BtnSee").GetComponentInChildren<Text>().text = value ? "隐藏界面" : "调试红外";
|
|
|
- if (value) InitInfraredCamera();
|
|
|
+ //if (value) InitInfraredCamera();
|
|
|
}
|
|
|
|
|
|
Text _spText;
|
|
|
@@ -73,32 +84,261 @@ public class InfraredDemo : MonoBehaviour
|
|
|
|
|
|
#region 红外摄像
|
|
|
[SerializeField] RawImage _cameraRender;
|
|
|
+ [SerializeField] MaintainAspectRatio _MaintainAspectRatio;
|
|
|
[SerializeField] List<RectTransform> _crosshairsInCamera;
|
|
|
|
|
|
- [SerializeField] Slider _sliderBrightness;
|
|
|
- [SerializeField] Slider _sliderSaturation;
|
|
|
- [SerializeField] Slider _sliderContrast;
|
|
|
+ //[SerializeField] Slider _sliderBrightness;
|
|
|
+ //[SerializeField] Slider _sliderSaturation;
|
|
|
+ //[SerializeField] Slider _sliderContrast;
|
|
|
[SerializeField] Slider _sliderShakeFilter;
|
|
|
|
|
|
[SerializeField] Button _btnReset;
|
|
|
[SerializeField] Button _btnScreenLocateManual;
|
|
|
+ [SerializeField] Button _btnScreenLocateManualAuto;
|
|
|
+ [SerializeField] Slider _sliderCapture;
|
|
|
+ [SerializeField] Slider _sliderDelay;
|
|
|
|
|
|
[SerializeField] Dropdown _dropdownResolution;
|
|
|
|
|
|
|
|
|
[SerializeField] Slider _sliderLineWidth;
|
|
|
|
|
|
- public ParamFloatValue brightness = new ParamFloatValue("ic_brightness", 1.0f);
|
|
|
- public ParamFloatValue saturation = new ParamFloatValue("ic_saturation", 1.0f);
|
|
|
- public ParamFloatValue contrast = new ParamFloatValue("ic_contrast", 1.0f);
|
|
|
+ //调试UVC参数
|
|
|
+ [SerializeField] GameObject _cameraParameterPanel;
|
|
|
+ //Dictionary<string, ParamFloatValue> dUVCParameters = new Dictionary<string, ParamFloatValue>();
|
|
|
+
|
|
|
+ //public ParamFloatValue brightness = new ParamFloatValue("ic_brightness", 1.0f);
|
|
|
+ //public ParamFloatValue saturation = new ParamFloatValue("ic_saturation", 1.0f);
|
|
|
+ //public ParamFloatValue contrast = new ParamFloatValue("ic_contrast", 1.0f);
|
|
|
+
|
|
|
public ParamFloatValue shakeFilterValue = new ParamFloatValue("ic_shakeFilterValue2", 6.0f);
|
|
|
public ParamFloatValue resoution = new ParamFloatValue("ic_resoution2", 2);
|
|
|
|
|
|
public ParamFloatValue lineWidth = new ParamFloatValue("ic_lineWidth", 20.0f);
|
|
|
|
|
|
+ public ParamFloatValue captureValue = new ParamFloatValue("ic_captureValue", 30.0f);
|
|
|
+ public ParamFloatValue delayValue = new ParamFloatValue("ic_delayValue", 30.0f);
|
|
|
+
|
|
|
public static InfraredCameraHelper infraredCameraHelper;
|
|
|
public static bool running { get => infraredCameraHelper != null; }
|
|
|
private bool _inited;
|
|
|
+
|
|
|
+
|
|
|
+ #region 参数控制
|
|
|
+
|
|
|
+
|
|
|
+ public GameObject togglePrefab; // 拖入一个Toggle预设体
|
|
|
+ public GameObject sliderPrefab; // 拖入一个Slider预设体
|
|
|
+ public GameObject spawnPoint;
|
|
|
+ //自动曝光
|
|
|
+ bool bAutoAE = false;
|
|
|
+ Toggle CTRLAEToggle;
|
|
|
+ Slider CTRLAEABSSlider;
|
|
|
+ string[] sliderNameArray = new string[]{
|
|
|
+ "自动曝光模式",
|
|
|
+ "曝光时间(绝对)",
|
|
|
+
|
|
|
+ "亮度", //
|
|
|
+ "对比度",
|
|
|
+ "色调",
|
|
|
+ "饱和度",
|
|
|
+ "锐度",
|
|
|
+ "伽玛",
|
|
|
+ //"白平衡温度",
|
|
|
+ //"白平衡分量",
|
|
|
+ "背光补偿",
|
|
|
+ "增益" };
|
|
|
+
|
|
|
+ string[] sliderStrArray = new string[]{
|
|
|
+ "CTRL_AE",
|
|
|
+ "CTRL_AE_ABS",
|
|
|
+
|
|
|
+ "PU_BRIGHTNESS",
|
|
|
+ "PU_CONTRAST",
|
|
|
+ "PU_HUE",
|
|
|
+ "PU_SATURATION",
|
|
|
+ "PU_SHARPNESS",
|
|
|
+ "PU_GAMMA",
|
|
|
+ //"PU_WB_TEMP",
|
|
|
+ //"PU_WB_COMPO",
|
|
|
+ "PU_BACKLIGHT",
|
|
|
+ "PU_GAIN" };
|
|
|
+
|
|
|
+ UVCManager.CameraInfo currentCameraInfo;
|
|
|
+ //初始化相机参数
|
|
|
+ public void initSlider(UVCManager.CameraInfo cameraInfo)
|
|
|
+ {
|
|
|
+ if (currentCameraInfo != null) return;
|
|
|
+ currentCameraInfo = cameraInfo;
|
|
|
+
|
|
|
+ for (int i = 0; i < sliderStrArray.Length; i++)
|
|
|
+ {
|
|
|
+ string typeStr = sliderStrArray[i];
|
|
|
+ UInt64 _VALUE = cameraInfo.GetTypeByName(typeStr);
|
|
|
+ //不支持的,跳过
|
|
|
+ bool bContains = cameraInfo.ContainsKey(_VALUE);
|
|
|
+ if (!bContains) continue;
|
|
|
+
|
|
|
+
|
|
|
+ if (typeStr == "CTRL_AE")
|
|
|
+ {
|
|
|
+ //曝光Toggle
|
|
|
+ GameObject toggleObject = Instantiate(togglePrefab, spawnPoint.transform);
|
|
|
+ toggleObject.SetActive(true);
|
|
|
+ toggleObject.name = typeStr;
|
|
|
+
|
|
|
+ Text labelObj = toggleObject.transform.Find("Label").GetComponent<Text>();
|
|
|
+ labelObj.text = sliderNameArray[i];
|
|
|
+ Toggle toggle = toggleObject.GetComponent<Toggle>();
|
|
|
+ CTRLAEToggle = toggle;
|
|
|
+
|
|
|
+ UVCCtrlInfo _AEInfo = cameraInfo.GetInfo(_VALUE);
|
|
|
+ Debug.Log("UVCCtrlInfo:"+_AEInfo.ToString());
|
|
|
+
|
|
|
+ int _currentValue = cameraInfo.GetValue(_VALUE);
|
|
|
+ bAutoAE = _currentValue == 8? true:false; //如果当前值是 8,则当前摄像机是自动曝光模式
|
|
|
+ toggle.isOn = bAutoAE;
|
|
|
+ //cameraInfo.SetValue(_VALUE, _currentValue!=8? 8:1);
|
|
|
+
|
|
|
+ toggle.onValueChanged.AddListener((bool bValue) =>
|
|
|
+ {
|
|
|
+ //Debug.Log("Toggle value changed to: " + bValue + " from " + _VALUE);
|
|
|
+ if (typeStr == "CTRL_AE")
|
|
|
+ {
|
|
|
+ //开关控制是否自动曝光
|
|
|
+ bAutoAE = bValue;
|
|
|
+ if (CTRLAEABSSlider) CTRLAEABSSlider.interactable = !bAutoAE;
|
|
|
+ int _value = bValue ? 8 : 1;
|
|
|
+ //Debug.Log("_value " + _value);
|
|
|
+ cameraInfo.SetValue(_VALUE, _value);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //其余使用slider
|
|
|
+ GameObject sliderObject = Instantiate(sliderPrefab, spawnPoint.transform);
|
|
|
+ sliderObject.SetActive(true);
|
|
|
+ sliderObject.name = typeStr;
|
|
|
+
|
|
|
+ Slider slider = sliderObject.GetComponent<Slider>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Text textObj = sliderObject.transform.Find("text").GetComponent<Text>();
|
|
|
+ Text titleTextObj = sliderObject.transform.Find("title").GetComponent<Text>();
|
|
|
+ titleTextObj.text = sliderNameArray[i];//类型名字
|
|
|
+ if (slider != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ UVCCtrlInfo _UVCCtrlInfo = cameraInfo.GetInfo(_VALUE);
|
|
|
+ slider.minValue = _UVCCtrlInfo.min;
|
|
|
+ slider.maxValue = _UVCCtrlInfo.max;
|
|
|
+ slider.wholeNumbers = true;
|
|
|
+
|
|
|
+
|
|
|
+ //记录一个typeStr类型的数据存储操作对象
|
|
|
+ ParamFloatValue paramFloatValue = new ParamFloatValue("ic_uvc_" + typeStr, _UVCCtrlInfo.def);
|
|
|
+ //dUVCParameters.Add(typeStr, paramFloatValue);
|
|
|
+ //获取当前值
|
|
|
+ int _currentValue = cameraInfo.GetValue(_VALUE);
|
|
|
+ //int _saveValue = (int)dUVCParameters.GetValueOrDefault(typeStr).Get();
|
|
|
+
|
|
|
+ slider.value = _currentValue;
|
|
|
+ textObj.text = _currentValue + "";
|
|
|
+
|
|
|
+ //存储初始值,设置一次到UVC参数
|
|
|
+ Debug.Log(_UVCCtrlInfo.ToString());
|
|
|
+ Debug.Log("dUVCParameters2:" + _currentValue + " == " + _UVCCtrlInfo.def);
|
|
|
+
|
|
|
+ //如果是曝光slider
|
|
|
+ if (typeStr == "CTRL_AE_ABS")
|
|
|
+ {
|
|
|
+ CTRLAEABSSlider = slider;
|
|
|
+ slider.interactable = !bAutoAE;
|
|
|
+ //if (!bAutoAE) {
|
|
|
+ // cameraInfo.SetValue(_VALUE, (int)paramFloatValue.Get());
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ //else{
|
|
|
+ // if (_currentValue != _saveValue) cameraInfo.SetValue(_VALUE, (int)paramFloatValue.Get());
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ slider.onValueChanged.AddListener((newValue) =>
|
|
|
+ {
|
|
|
+ var _value = Mathf.FloorToInt(newValue);
|
|
|
+ textObj.text = _value + "";
|
|
|
+ //Debug.Log("Slider value changed to: " + newValue + " from " + _VALUE);
|
|
|
+ cameraInfo.SetValue(_VALUE, _value);
|
|
|
+ //存储值
|
|
|
+ //dUVCParameters.GetValueOrDefault(typeStr).Set(_value);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OpenUVCPanel() {
|
|
|
+ _cameraParameterPanel.SetActive(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void CloseUVCPanel() {
|
|
|
+ _cameraParameterPanel.SetActive(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void onResetUVCData() {
|
|
|
+
|
|
|
+ if(currentCameraInfo == null) return;
|
|
|
+
|
|
|
+ for (int i = 0; i < sliderStrArray.Length; i++)
|
|
|
+ {
|
|
|
+ string typeStr = sliderStrArray[i];
|
|
|
+ UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
|
|
|
+ bool bContains = currentCameraInfo.ContainsKey(_VALUE);
|
|
|
+ if (!bContains) continue;
|
|
|
+
|
|
|
+ if (typeStr == "CTRL_AE")
|
|
|
+ {
|
|
|
+ //toggle值不进行重置
|
|
|
+ Debug.Log("CTRL_AE 不需要重置");
|
|
|
+ }
|
|
|
+ else if (typeStr == "CTRL_AE_ABS" ) {
|
|
|
+ if (!bAutoAE) {
|
|
|
+ //如果是手动曝光,重置值
|
|
|
+ Transform trans = _cameraParameterPanel.transform.Find(typeStr);
|
|
|
+ Slider slider = trans.GetComponent<Slider>();
|
|
|
+ Text textObj = trans.Find("text").GetComponent<Text>();
|
|
|
+ UVCCtrlInfo _AEInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
+ //获取当前值
|
|
|
+ int _currentValue = currentCameraInfo.GetValue(_VALUE);
|
|
|
+ Debug.Log("CTRL_AE_ABS:" + _currentValue + " = " + _AEInfo.def + " = " + ",bAutoAE:" + bAutoAE);
|
|
|
+ textObj.text = _AEInfo.def + "";
|
|
|
+ slider.value = _AEInfo.def;
|
|
|
+ if (_AEInfo.def != _currentValue) currentCameraInfo.SetValue(_VALUE, _AEInfo.def);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Transform trans = _cameraParameterPanel.transform.Find(typeStr);
|
|
|
+ Slider slider = trans.GetComponent<Slider>();
|
|
|
+ Text textObj = trans.Find("text").GetComponent<Text>();
|
|
|
+ UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
+ textObj.text = _UVCCtrlInfo.def + "";
|
|
|
+ slider.value = _UVCCtrlInfo.def;
|
|
|
+ //获取当前值
|
|
|
+ int _currentValue = currentCameraInfo.GetValue(_VALUE);
|
|
|
+ //重置存储值
|
|
|
+ //dUVCParameters.GetValueOrDefault(typeStr).Set(_UVCCtrlInfo.def);
|
|
|
+ //存储初始值,设置一次到UVC参数
|
|
|
+ if (_UVCCtrlInfo.def != _currentValue) currentCameraInfo.SetValue(_VALUE, _UVCCtrlInfo.def);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
void InitInfraredCamera()
|
|
|
{
|
|
|
if (_inited) return;
|
|
|
@@ -110,6 +350,7 @@ public class InfraredDemo : MonoBehaviour
|
|
|
infraredCameraHelper.Create();
|
|
|
infraredCameraHelper.OnPositionUpdate += (Vector2 point) =>
|
|
|
{
|
|
|
+ if (Camera.main == null) return;
|
|
|
Ray ray = Camera.main.ScreenPointToRay(point);
|
|
|
Vector3 rayEndPoint = ray.GetPoint(200);
|
|
|
Quaternion quat = Quaternion.LookRotation(rayEndPoint - Camera.main.transform.position);
|
|
|
@@ -121,19 +362,30 @@ public class InfraredDemo : MonoBehaviour
|
|
|
if (CameraToLook.ins != null) CameraToLook.ins.localRotation = quat;
|
|
|
if (SB_EventSystem.ins) SB_EventSystem.ins.MoveSimulateMouseByInfrared(point);
|
|
|
};
|
|
|
+ infraredCameraHelper.OnUVCIsReady += (UVCManager.CameraInfo camera) =>
|
|
|
+ {
|
|
|
+ //生成控制摄像机的参数滑条
|
|
|
+ Debug.Log("初始化摄像机!");
|
|
|
+ initSlider(camera);
|
|
|
+ //_cameraRender.texture = ScreenLocate.Main.getUVCTexture; //infraredCameraHelper.GetCameraTexture();
|
|
|
+ //_cameraRender.SetNativeSize();
|
|
|
+ };
|
|
|
+ //InfraredCameraHelper.InfraredCameraHelperRawImageList.Add(_cameraRender);
|
|
|
+
|
|
|
}
|
|
|
//参数面板
|
|
|
- SetBrightness(brightness.Get());
|
|
|
- SetSaturation(saturation.Get());
|
|
|
- SetContrast(contrast.Get());
|
|
|
SetShakeFilterValue(shakeFilterValue.Get());
|
|
|
- _sliderBrightness.onValueChanged.AddListener(SetBrightness);
|
|
|
- _sliderSaturation.onValueChanged.AddListener(SetSaturation);
|
|
|
- _sliderContrast.onValueChanged.AddListener(SetContrast);
|
|
|
_sliderShakeFilter.onValueChanged.AddListener(SetShakeFilterValue);
|
|
|
//功能按钮
|
|
|
_btnReset.onClick.AddListener(OnClick_Reset);
|
|
|
_btnScreenLocateManual.onClick.AddListener(OnClick_ScreenLocateManual);
|
|
|
+ _btnScreenLocateManualAuto.onClick.AddListener(OnClick_ScreenLocateManualAuto);
|
|
|
+
|
|
|
+ SetCaptureValue(captureValue.Get());
|
|
|
+ _sliderCapture.onValueChanged.AddListener(SetCaptureValue);
|
|
|
+ SetDelayValue(delayValue.Get());
|
|
|
+ _sliderDelay.onValueChanged.AddListener(SetDelayValue);
|
|
|
+
|
|
|
//分辨率
|
|
|
SetResolution((int)resoution.Get());
|
|
|
_dropdownResolution.onValueChanged.AddListener(v =>
|
|
|
@@ -145,7 +397,30 @@ public class InfraredDemo : MonoBehaviour
|
|
|
//绘制线段
|
|
|
SetLineWidth(lineWidth.Get());
|
|
|
_sliderLineWidth.onValueChanged.AddListener(SetLineWidth);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ public void onStartPreview() {
|
|
|
+ infraredCameraHelper.onStartPreview();
|
|
|
+ }
|
|
|
+ public void onStopPreview()
|
|
|
+ {
|
|
|
+ infraredCameraHelper.onStopPreview();
|
|
|
+ }
|
|
|
+ //获取并且初始化一次数据
|
|
|
+ void initScreenLocateManual()
|
|
|
+ {
|
|
|
+ ScreenLocate.GetScreenLocateVectorList();
|
|
|
+
|
|
|
+ infraredCameraHelper.QuitScreenLocateManual(ScreenLocate.quadUnityVectorList);
|
|
|
+
|
|
|
+ ScreenLocate.Main.SyncInfraredDemo();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
IEnumerator RestartOrKillApp()
|
|
|
{
|
|
|
yield return new WaitForSeconds(0.3f);
|
|
|
@@ -169,21 +444,20 @@ public class InfraredDemo : MonoBehaviour
|
|
|
}
|
|
|
else Application.Quit();
|
|
|
}
|
|
|
- public void SetBrightness(float v)
|
|
|
- {
|
|
|
- brightness.Set(v);
|
|
|
- _sliderBrightness.SetValueWithoutNotify(brightness.Get());
|
|
|
- _sliderBrightness.transform.Find("Value").GetComponent<Text>().text = brightness.Get().ToString("f1");
|
|
|
- infraredCameraHelper.SetBrightness(brightness.Get());
|
|
|
- }
|
|
|
+
|
|
|
void UpdateInfraredCamera()
|
|
|
{
|
|
|
if (!_visiable) return;
|
|
|
if (!_inited) return;
|
|
|
if (infraredCameraHelper == null) return;
|
|
|
//渲染相机画面
|
|
|
- _cameraRender.texture = infraredCameraHelper.GetCameraTexture();
|
|
|
- _cameraRender.material = infraredCameraHelper.GetCameraMaterial();
|
|
|
+ //_cameraRender.texture = infraredCameraHelper.GetCameraTexture();
|
|
|
+ //_cameraRender.material = infraredCameraHelper.GetCameraMaterial();
|
|
|
+ if (ScreenLocate.Main.getUVCTexture) {
|
|
|
+ _cameraRender.texture = ScreenLocate.Main.getUVCTexture;
|
|
|
+ _cameraRender.SetNativeSize();
|
|
|
+ _MaintainAspectRatio.AdjustSize();
|
|
|
+ }
|
|
|
//在相机画面显示准心
|
|
|
if (ScreenLocate.Main)
|
|
|
{
|
|
|
@@ -207,9 +481,11 @@ public class InfraredDemo : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public void SetLocatePointsToCameraRender(List<Vector2> points, float w, float h)
|
|
|
{
|
|
|
Transform pointsTF2 = _cameraRender.transform.Find("Points");
|
|
|
+
|
|
|
if (pointsTF2.childCount == points.Count)
|
|
|
{
|
|
|
Vector2 texSize = new Vector2(w, h);
|
|
|
@@ -222,20 +498,7 @@ public class InfraredDemo : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- void SetSaturation(float v)
|
|
|
- {
|
|
|
- saturation.Set(v);
|
|
|
- _sliderSaturation.SetValueWithoutNotify(saturation.Get());
|
|
|
- _sliderSaturation.transform.Find("Value").GetComponent<Text>().text = saturation.Get().ToString("f1");
|
|
|
- infraredCameraHelper.SetSaturation(saturation.Get());
|
|
|
- }
|
|
|
- void SetContrast(float v)
|
|
|
- {
|
|
|
- contrast.Set(v);
|
|
|
- _sliderContrast.SetValueWithoutNotify(contrast.Get());
|
|
|
- _sliderContrast.transform.Find("Value").GetComponent<Text>().text = contrast.Get().ToString("f1");
|
|
|
- infraredCameraHelper.SetContrast(contrast.Get());
|
|
|
- }
|
|
|
+
|
|
|
void SetShakeFilterValue(float v)
|
|
|
{
|
|
|
shakeFilterValue.Set(v);
|
|
|
@@ -284,18 +547,38 @@ public class InfraredDemo : MonoBehaviour
|
|
|
}
|
|
|
void OnClick_Reset()
|
|
|
{
|
|
|
- SetBrightness(1);
|
|
|
- SetSaturation(1);
|
|
|
- SetContrast(1);
|
|
|
+ //SetBrightness(1);
|
|
|
+ //SetSaturation(1);
|
|
|
+ //SetContrast(1);
|
|
|
+
|
|
|
SetShakeFilterValue(6);
|
|
|
|
|
|
- SetLineWidth(20);
|
|
|
+ SetLineWidth(10);
|
|
|
}
|
|
|
void OnClick_ScreenLocateManual()
|
|
|
{
|
|
|
ViewManager2.ShowView(ViewManager2.Path_InfraredScreenPositioningView);
|
|
|
FindObjectOfType<InfraredScreenPositioningView>().enterFromInfraredDemo = true;
|
|
|
}
|
|
|
+
|
|
|
+ void OnClick_ScreenLocateManualAuto() {
|
|
|
+ infraredCameraHelper.EnterScreenLocateManualAuto();
|
|
|
+ }
|
|
|
+
|
|
|
+ void SetCaptureValue(float v)
|
|
|
+ {
|
|
|
+ captureValue.Set(v);
|
|
|
+ _sliderCapture.SetValueWithoutNotify(captureValue.Get());
|
|
|
+ _sliderCapture.transform.Find("Value").GetComponent<Text>().text = captureValue.Get().ToString("f1");
|
|
|
+ infraredCameraHelper.SetCapture( (int)captureValue.Get());
|
|
|
+ }
|
|
|
+ void SetDelayValue(float v)
|
|
|
+ {
|
|
|
+ delayValue.Set(v);
|
|
|
+ _sliderDelay.SetValueWithoutNotify(delayValue.Get());
|
|
|
+ _sliderDelay.transform.Find("Value").GetComponent<Text>().text = delayValue.Get().ToString("f1");
|
|
|
+ infraredCameraHelper.SetDelay((int)delayValue.Get());
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@@ -304,8 +587,13 @@ public class InfraredDemo : MonoBehaviour
|
|
|
{
|
|
|
if (running)
|
|
|
{
|
|
|
- float v = infraredCameraHelper.GetBrightness();
|
|
|
- _slider.SetValueWithoutNotify(v);
|
|
|
+ string typeStr = "PU_BRIGHTNESS";
|
|
|
+ UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
|
|
|
+ UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
+ float v = currentCameraInfo.GetValue(_VALUE); // infraredCameraHelper.GetBrightness();
|
|
|
+ float v2 = (v / _UVCCtrlInfo.max) * 10;
|
|
|
+ Debug.Log("获取相机的感光度:" + _VALUE + " = " + v + " = " + v2);
|
|
|
+ _slider.SetValueWithoutNotify(v2);
|
|
|
}
|
|
|
else _slider.SetValueWithoutNotify(5);
|
|
|
}
|
|
|
@@ -315,9 +603,26 @@ public class InfraredDemo : MonoBehaviour
|
|
|
//修改亮度时,调试界面的亮度也应该一起修改
|
|
|
if (running)
|
|
|
{
|
|
|
- Slider slider = transform.Find("InfraredCamera/Layout/SliderBrightness")
|
|
|
- .GetComponent<Slider>();
|
|
|
- slider.value = value;
|
|
|
+ //Slider slider = transform.Find("InfraredCamera/Layout/SliderBrightness")
|
|
|
+ // .GetComponent<Slider>();
|
|
|
+
|
|
|
+ string typeStr = "PU_BRIGHTNESS";
|
|
|
+ UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
|
|
|
+ Transform trans = _cameraParameterPanel.transform.Find(typeStr);
|
|
|
+ Slider slider = trans.GetComponent<Slider>();
|
|
|
+
|
|
|
+ Text textObj = trans.Find("text").GetComponent<Text>();
|
|
|
+ UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
+ int _currentUVCValue = currentCameraInfo.GetValue(_VALUE);
|
|
|
+ //value 0 ~ 10
|
|
|
+ int _current = (int)(_UVCCtrlInfo.max * value / 10);
|
|
|
+ Debug.Log("_current:" + value);
|
|
|
+ textObj.text = _current + "";
|
|
|
+ slider.value = _current;
|
|
|
+ //dUVCParameters.GetValueOrDefault(typeStr).Set(_current);
|
|
|
+ //存储初始值,设置一次到UVC参数
|
|
|
+ if(_currentUVCValue != _current) currentCameraInfo.SetValue(_VALUE, _current);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
#endregion
|