|
@@ -128,6 +128,9 @@ public class InfraredDemo : MonoBehaviour
|
|
|
//亮度过滤阈值
|
|
//亮度过滤阈值
|
|
|
public ParamFloatValue infraredFileterValue = new ParamFloatValue("ic_infraredFileterValue", 0.8f);
|
|
public ParamFloatValue infraredFileterValue = new ParamFloatValue("ic_infraredFileterValue", 0.8f);
|
|
|
|
|
|
|
|
|
|
+ //十字准心
|
|
|
|
|
+ public ParamFloatValue crosshairValue = new ParamFloatValue("ic_crosshairValue",0);
|
|
|
|
|
+
|
|
|
public static InfraredCameraHelper infraredCameraHelper;
|
|
public static InfraredCameraHelper infraredCameraHelper;
|
|
|
public static bool running { get => infraredCameraHelper != null; }
|
|
public static bool running { get => infraredCameraHelper != null; }
|
|
|
private bool _inited;
|
|
private bool _inited;
|
|
@@ -366,6 +369,8 @@ public class InfraredDemo : MonoBehaviour
|
|
|
infraredCameraHelper.Create();
|
|
infraredCameraHelper.Create();
|
|
|
infraredCameraHelper.OnPositionUpdate += (Vector2 point) =>
|
|
infraredCameraHelper.OnPositionUpdate += (Vector2 point) =>
|
|
|
{
|
|
{
|
|
|
|
|
+ //跑九轴时候,不处理这里位置
|
|
|
|
|
+ if (AimHandler.ins && AimHandler.ins.bRuning9Axis()) return;
|
|
|
if (Camera.main == null) return;
|
|
if (Camera.main == null) return;
|
|
|
Ray ray = Camera.main.ScreenPointToRay(point);
|
|
Ray ray = Camera.main.ScreenPointToRay(point);
|
|
|
Vector3 rayEndPoint = ray.GetPoint(200);
|
|
Vector3 rayEndPoint = ray.GetPoint(200);
|
|
@@ -426,6 +431,14 @@ public class InfraredDemo : MonoBehaviour
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public int getCrosshairValue() {
|
|
|
|
|
+ return (int)crosshairValue.Get();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setCrosshairValue(bool bshow) {
|
|
|
|
|
+ crosshairValue.Set(bshow?1:0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void onStartPreview()
|
|
public void onStartPreview()
|
|
|
{
|
|
{
|
|
|
infraredCameraHelper.onStartPreview();
|
|
infraredCameraHelper.onStartPreview();
|
|
@@ -670,9 +683,19 @@ public class InfraredDemo : MonoBehaviour
|
|
|
UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
|
|
UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
|
|
|
UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
float v = currentCameraInfo.GetValue(_VALUE); // infraredCameraHelper.GetBrightness();
|
|
float v = currentCameraInfo.GetValue(_VALUE); // infraredCameraHelper.GetBrightness();
|
|
|
- float v2 = (v / _UVCCtrlInfo.max) * 10;
|
|
|
|
|
|
|
+ //float v2 = (v / _UVCCtrlInfo.max) * 10;
|
|
|
|
|
+
|
|
|
|
|
+ // 目标区间 [0, 10] 的边界值
|
|
|
|
|
+ double targetMin = 0.0;
|
|
|
|
|
+ double targetMax = 10.0;
|
|
|
|
|
+ double originalMin = _UVCCtrlInfo.min;
|
|
|
|
|
+ double originalMax = _UVCCtrlInfo.max;
|
|
|
|
|
+ // 计算转换后的值
|
|
|
|
|
+ double v2 = MapValue(v, originalMin, originalMax, targetMin, targetMax);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
Debug.Log("获取相机的感光度:" + _VALUE + " = " + v + " = " + v2);
|
|
Debug.Log("获取相机的感光度:" + _VALUE + " = " + v + " = " + v2);
|
|
|
- _slider.SetValueWithoutNotify(v2);
|
|
|
|
|
|
|
+ _slider.SetValueWithoutNotify((float)v2);
|
|
|
}
|
|
}
|
|
|
else _slider.SetValueWithoutNotify(5);
|
|
else _slider.SetValueWithoutNotify(5);
|
|
|
}
|
|
}
|
|
@@ -694,8 +717,16 @@ public class InfraredDemo : MonoBehaviour
|
|
|
UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
|
|
|
int _currentUVCValue = currentCameraInfo.GetValue(_VALUE);
|
|
int _currentUVCValue = currentCameraInfo.GetValue(_VALUE);
|
|
|
//value 0 ~ 10
|
|
//value 0 ~ 10
|
|
|
- int _current = (int)(_UVCCtrlInfo.max * value / 10);
|
|
|
|
|
- Debug.Log("_current:" + value);
|
|
|
|
|
|
|
+ // 原始区间和目标区间的边界值
|
|
|
|
|
+ double originalMin = 0.0;
|
|
|
|
|
+ double originalMax = 10.0;
|
|
|
|
|
+ double targetMin = _UVCCtrlInfo.min;
|
|
|
|
|
+ double targetMax = _UVCCtrlInfo.max;
|
|
|
|
|
+ // 计算转换后的值
|
|
|
|
|
+ double result = MapValue(value, originalMin, originalMax, targetMin, targetMax);
|
|
|
|
|
+
|
|
|
|
|
+ int _current = (int)(result);
|
|
|
|
|
+ Debug.Log("_current:" + value + " , result:" + result);
|
|
|
textObj.text = _current + "";
|
|
textObj.text = _current + "";
|
|
|
slider.value = _current;
|
|
slider.value = _current;
|
|
|
//dUVCParameters.GetValueOrDefault(typeStr).Set(_current);
|
|
//dUVCParameters.GetValueOrDefault(typeStr).Set(_current);
|
|
@@ -704,6 +735,12 @@ public class InfraredDemo : MonoBehaviour
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ double MapValue(double value, double originalMin, double originalMax, double targetMin, double targetMax)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 线性插值公式
|
|
|
|
|
+ return targetMin + (value - originalMin) * (targetMax - targetMin) / (originalMax - originalMin);
|
|
|
|
|
+ }
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|