Browse Source

feat: 动态解析 ZoomVaryFunc

master
fajiao 2 years ago
parent
commit
1e6cae26bd
  1. 5
      Cis.Application/Cis.Application.xml
  2. 9
      Cis.Application/Core/Component/MarkSeacher/Entity/CameraCalcParams.cs
  3. 7
      Cis.Application/Core/Component/MarkSeacher/MarkSearcherServer.cs
  4. 5
      Cis.Application/Core/Component/MarkSeacher/Seacher/DaHuaMarkSearcher.cs
  5. 8
      Cis.Application/Core/Component/MarkSeacher/Seacher/HiKMarkSeacher.cs
  6. 2
      Cis.Web.Entry/Properties/launchSettings.json

5
Cis.Application/Cis.Application.xml

@ -506,6 +506,11 @@
FocusY
</summary>
</member>
<member name="P:Cis.Application.Core.Component.MarkSeacher.CameraCalcParams.ZoomVaryExpr">
<summary>
ZoomVaryExpr
</summary>
</member>
<member name="P:Cis.Application.Core.Component.MarkSeacher.CameraCalcParams.VideoWidth">
<summary>
视频宽度

9
Cis.Application/Core/Component/MarkSeacher/Entity/CameraCalcParams.cs

@ -1,4 +1,5 @@
using EC.Helper.CameraSDK;
using EC.Helper.RabbitFunc.Expressions;
namespace Cis.Application.Core.Component.MarkSeacher;
@ -27,6 +28,11 @@ public class CameraCalcParams
/// </summary>
public double FocusY { get; set; }
/// <summary>
/// ZoomVaryExpr
/// </summary>
public LambdaExpression ZoomVaryExpr { get; set; }
/// <summary>
/// 视频宽度
/// </summary>
@ -37,7 +43,7 @@ public class CameraCalcParams
/// </summary>
public int VideoHeight { get; set; }
public static CameraCalcParams New(long id, PtzInfo ptzInfo, double focusX, double focusY, int videoWidth = 1920, int videoHeight = 1080)
public static CameraCalcParams New(long id, PtzInfo ptzInfo, double focusX, double focusY, LambdaExpression ZoomVaryExpr, int videoWidth = 1920, int videoHeight = 1080)
{
return new()
{
@ -45,6 +51,7 @@ public class CameraCalcParams
PtzInfo = ptzInfo,
FocusX = focusX,
FocusY = focusY,
ZoomVaryExpr = ZoomVaryExpr,
VideoWidth = videoWidth,
VideoHeight = videoHeight,
};

7
Cis.Application/Core/Component/MarkSeacher/MarkSearcherServer.cs

@ -2,6 +2,8 @@
using Cis.Application.Cm;
using Cis.Application.Core.Component.PtzServer;
using EC.Helper.CameraSDK;
using EC.Helper.RabbitFunc;
using EC.Helper.RabbitFunc.Expressions;
using FreeRedis;
using System.Collections.Concurrent;
@ -97,8 +99,11 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton
ret = _cameraSdkServer.TryGetPtzInfoByIp(cbCamera.Ip, out PtzInfo ptzInfo);
if (!ret) return false;
// 解析 ZoomVaryFunc
LambdaExpression zoomVaryExpr = RabbitFuncUtil.CompileFromSource(cbCameraParams.ZoomVaryFunc);
// 创建相机计算参数
CameraCalcParams cameraCalcParams = CameraCalcParams.New(cbCamera.Id, ptzInfo, cbCameraParams.FocusX, cbCameraParams.FocusY);
CameraCalcParams cameraCalcParams = CameraCalcParams.New(cbCamera.Id, ptzInfo, cbCameraParams.FocusX, cbCameraParams.FocusY, zoomVaryExpr);
// 创建 markSearcher
MarkSearcherBase markSearcher = ((CameraType)cbCameraParams.CameraType).CreateMarkSearcher(cameraCalcParams);
if (markSearcher == null) return false;

5
Cis.Application/Core/Component/MarkSeacher/Seacher/DaHuaMarkSearcher.cs

@ -22,7 +22,10 @@ public class DaHuaMarkSearcher : MarkSearcherBase
protected override double GetZoomTag(double zoomPos)
{
double ret = zoomPos / (128.0 / 42.0) + 1;
double ret = (double)CameraCalcParams.ZoomVaryExpr.Eval(new()
{
["x"] = zoomPos,
});
return ret;
}

8
Cis.Application/Core/Component/MarkSeacher/Seacher/HiKMarkSeacher.cs

@ -29,8 +29,10 @@ public class HiKMarkSearcher : MarkSearcherBase
protected override double GetZoomTag(double zoomPos)
{
double ret = HexToDecMa(zoomPos) * 0.1;
ret = (ret - 1) * 0.65 + 1;
double ret = (double)CameraCalcParams.ZoomVaryExpr.Eval(new()
{
["x"] = HexToDecMa(zoomPos),
});
return ret;
}
@ -38,7 +40,7 @@ public class HiKMarkSearcher : MarkSearcherBase
#region Util
protected int HexToDecMa(double wHex)
protected static int HexToDecMa(double wHex)
{
int wHexInt = wHex.ToInt();
int ret = (wHexInt / 4096) * 1000 + ((wHexInt % 4096) / 256) * 100 + ((wHexInt % 256) / 16) * 10 + (wHexInt % 16);

2
Cis.Web.Entry/Properties/launchSettings.json

@ -9,7 +9,7 @@
},
"Cis.Web.Entry": {
"commandName": "Project",
"launchBrowser": true,
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},

Loading…
Cancel
Save