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 FocusY
</summary> </summary>
</member> </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"> <member name="P:Cis.Application.Core.Component.MarkSeacher.CameraCalcParams.VideoWidth">
<summary> <summary>
视频宽度 视频宽度

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

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

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

@ -2,6 +2,8 @@
using Cis.Application.Cm; using Cis.Application.Cm;
using Cis.Application.Core.Component.PtzServer; using Cis.Application.Core.Component.PtzServer;
using EC.Helper.CameraSDK; using EC.Helper.CameraSDK;
using EC.Helper.RabbitFunc;
using EC.Helper.RabbitFunc.Expressions;
using FreeRedis; using FreeRedis;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -97,8 +99,11 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton
ret = _cameraSdkServer.TryGetPtzInfoByIp(cbCamera.Ip, out PtzInfo ptzInfo); ret = _cameraSdkServer.TryGetPtzInfoByIp(cbCamera.Ip, out PtzInfo ptzInfo);
if (!ret) return false; 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 // 创建 markSearcher
MarkSearcherBase markSearcher = ((CameraType)cbCameraParams.CameraType).CreateMarkSearcher(cameraCalcParams); MarkSearcherBase markSearcher = ((CameraType)cbCameraParams.CameraType).CreateMarkSearcher(cameraCalcParams);
if (markSearcher == null) return false; 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) 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; 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) protected override double GetZoomTag(double zoomPos)
{ {
double ret = HexToDecMa(zoomPos) * 0.1; double ret = (double)CameraCalcParams.ZoomVaryExpr.Eval(new()
ret = (ret - 1) * 0.65 + 1; {
["x"] = HexToDecMa(zoomPos),
});
return ret; return ret;
} }
@ -38,7 +40,7 @@ public class HiKMarkSearcher : MarkSearcherBase
#region Util #region Util
protected int HexToDecMa(double wHex) protected static int HexToDecMa(double wHex)
{ {
int wHexInt = wHex.ToInt(); int wHexInt = wHex.ToInt();
int ret = (wHexInt / 4096) * 1000 + ((wHexInt % 4096) / 256) * 100 + ((wHexInt % 256) / 16) * 10 + (wHexInt % 16); 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": { "Cis.Web.Entry": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": false,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },

Loading…
Cancel
Save