From 43466f032e2d2a4a5145fd3b488e69d246b13941 Mon Sep 17 00:00:00 2001 From: fajiao <1519100073@qq.com> Date: Thu, 27 Oct 2022 10:04:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=BF=BD=E8=B8=AA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cis.Application/Cb/Service/CbCameraService.cs | 35 +++--- Cis.Application/Cis.Application.xml | 36 +++--- Cis.Application/Cm/Entity/CmMarkLabel.cs | 16 +-- .../Cm/Service/CmMarkGroupService.cs | 12 +- .../Cm/Service/CmMarkLabelService.cs | 39 +++++-- Cis.Application/Core/Algo/HikMarkSeacher.cs | 17 +-- Cis.Application/Core/Algo/MarkSearcherBase.cs | 73 ++++++------ .../Core/Center/CameraDataCenter.cs | 107 +++++++++++------- Cis.Application/Core/Entity/CameraCalcInfo.cs | 59 ++++++---- .../Core/Service/MarkSearchService.cs | 28 +++-- Cis.Application/Startup.cs | 2 +- .../Sys/Service/SysDictDataService.cs | 12 +- .../Sys/Service/SysDictTypeService.cs | 12 +- .../Tb/Service/TbPtzCameraService.cs | 12 +- 14 files changed, 274 insertions(+), 186 deletions(-) diff --git a/Cis.Application/Cb/Service/CbCameraService.cs b/Cis.Application/Cb/Service/CbCameraService.cs index a3d61f5..febfc89 100644 --- a/Cis.Application/Cb/Service/CbCameraService.cs +++ b/Cis.Application/Cb/Service/CbCameraService.cs @@ -15,6 +15,24 @@ public class CbCameraService : IDynamicApiController, ITransient _cbCameraRep = cbCameraRep; } + [HttpPost] + public async Task Add([FromForm] CbCamera entity) + { + return await _cbCameraRep.InsertAsync(entity); + } + + [HttpPost] + public async Task Update([FromForm] CbCamera entity) + { + return await _cbCameraRep.UpdateAsync(entity); + } + + [HttpPost] + public async Task Delete([FromForm] CbCamera entity) + { + return await _cbCameraRep.DeleteAsync(entity); + } + [HttpGet] public async Task Get(long id) { @@ -41,21 +59,4 @@ public class CbCameraService : IDynamicApiController, ITransient return list; } - [HttpPost] - public async Task Add(CbCamera entity) - { - await _cbCameraRep.InsertAsync(entity); - } - - [HttpPost] - public async Task Update(CbCamera entity) - { - await _cbCameraRep.UpdateAsync(entity); - } - - [HttpPost] - public async Task Delete(CbCamera entity) - { - await _cbCameraRep.DeleteAsync(entity); - } } \ No newline at end of file diff --git a/Cis.Application/Cis.Application.xml b/Cis.Application/Cis.Application.xml index 20d2139..4df3d6c 100644 --- a/Cis.Application/Cis.Application.xml +++ b/Cis.Application/Cis.Application.xml @@ -297,14 +297,14 @@ 循环运行 - + 激活 cbCamera 进入运算 - + 解除 cbCamera 进入运算 @@ -356,14 +356,14 @@ Ptz 信息 - + - 图像的宽度 + 视频的宽度 - + - 图像的高度 + 视频的高度 @@ -406,24 +406,24 @@ Ptz 信息 - + - 画布宽度 + 视频宽度 - + - 画布高度 + 视频高度 - + - 画布 left 距离 + 画布 left 距离比例 - + - 画布 top 距离 + 画布 top 距离比例 @@ -442,14 +442,14 @@ false 不显示(不在当前视频画面里面) - + - 画布 left 距离 + 画布 left 距离比例 - + - 画布 top 距离 + 画布 top 距离比例 diff --git a/Cis.Application/Cm/Entity/CmMarkLabel.cs b/Cis.Application/Cm/Entity/CmMarkLabel.cs index cb19a1f..09e3617 100644 --- a/Cis.Application/Cm/Entity/CmMarkLabel.cs +++ b/Cis.Application/Cm/Entity/CmMarkLabel.cs @@ -43,17 +43,17 @@ public class CmMarkLabel : EntityBase [SugarColumn(ColumnDescription = "Zoom坐标")] public double ZoomPosition { get; set; } - [SugarColumn(ColumnDescription = "画布宽度")] - public double CanvasWidth { get; set; } + [SugarColumn(ColumnDescription = "视频宽度")] + public double VideoWidth { get; set; } - [SugarColumn(ColumnDescription = "画布高度")] - public double CanvasHeight { get; set; } + [SugarColumn(ColumnDescription = "视频高度")] + public double VideoHeight { get; set; } - [SugarColumn(ColumnDescription = "画布 left 距离")] - public double CanvasLeft { get; set; } + [SugarColumn(ColumnDescription = "画布 left 距离比例")] + public double CanvasLeftRatio { get; set; } - [SugarColumn(ColumnDescription = "画布 top 距离")] - public double CanvasTop { get; set; } + [SugarColumn(ColumnDescription = "画布 top 距离比例")] + public double CanvasTopRatio { get; set; } /// /// 备注 diff --git a/Cis.Application/Cm/Service/CmMarkGroupService.cs b/Cis.Application/Cm/Service/CmMarkGroupService.cs index 17ce798..0b9d9df 100644 --- a/Cis.Application/Cm/Service/CmMarkGroupService.cs +++ b/Cis.Application/Cm/Service/CmMarkGroupService.cs @@ -16,21 +16,21 @@ public class CmMarkGroupService : IDynamicApiController, ITransient } [HttpPost] - public async Task Add(CmMarkGroup entity) + public async Task Add([FromForm] CmMarkGroup entity) { - await _cmMarkGroupRep.InsertAsync(entity); + return await _cmMarkGroupRep.InsertAsync(entity); } [HttpPost] - public async Task Update(CmMarkGroup entity) + public async Task Update([FromForm] CmMarkGroup entity) { - await _cmMarkGroupRep.UpdateAsync(entity); + return await _cmMarkGroupRep.UpdateAsync(entity); } [HttpPost] - public async Task Delete(CmMarkGroup entity) + public async Task Delete([FromForm] CmMarkGroup entity) { - await _cmMarkGroupRep.DeleteAsync(entity); + return await _cmMarkGroupRep.DeleteAsync(entity); } [HttpGet] diff --git a/Cis.Application/Cm/Service/CmMarkLabelService.cs b/Cis.Application/Cm/Service/CmMarkLabelService.cs index 4840182..853af86 100644 --- a/Cis.Application/Cm/Service/CmMarkLabelService.cs +++ b/Cis.Application/Cm/Service/CmMarkLabelService.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json.Linq; +using Cis.Application.Core; +using Newtonsoft.Json.Linq; namespace Cis.Application.Cm; @@ -10,27 +11,50 @@ public class CmMarkLabelService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _cmMarkLabelRep; - public CmMarkLabelService(SqlSugarRepository cmMarkLabelRep) + private CameraDataCenter _cameraDataCenter { get; set; } + + public CmMarkLabelService(CameraDataCenter cameraDataCenter, + SqlSugarRepository cmMarkLabelRep) { + _cameraDataCenter = cameraDataCenter; _cmMarkLabelRep = cmMarkLabelRep; } [HttpPost] - public async Task Add(CmMarkLabel entity) + public async Task Add([FromForm] CmMarkLabel entity) + { + PtzInfo ptzInfo = _cameraDataCenter.GetCameraPtzInfo(entity.CbCameraId); + if (ptzInfo == null) + return false; + entity.PanPosition = ptzInfo.Pan; + entity.TiltPosition = ptzInfo.Tilt; + entity.ZoomPosition = ptzInfo.Zoom; + return await _cmMarkLabelRep.InsertAsync(entity); + } + + [HttpPost] + public async Task AddReturnId([FromForm] CmMarkLabel entity) { + PtzInfo ptzInfo = _cameraDataCenter.GetCameraPtzInfo(entity.CbCameraId); + if (ptzInfo == null) + return 0; + entity.PanPosition = ptzInfo.Pan; + entity.TiltPosition = ptzInfo.Tilt; + entity.ZoomPosition = ptzInfo.Zoom; await _cmMarkLabelRep.InsertAsync(entity); + return entity.Id; } [HttpPost] - public async Task Update(CmMarkLabel entity) + public async Task Update([FromForm] CmMarkLabel entity) { - await _cmMarkLabelRep.UpdateAsync(entity); + return await _cmMarkLabelRep.UpdateAsync(entity); } [HttpPost] - public async Task Delete(CmMarkLabel entity) + public async Task Delete([FromForm] CmMarkLabel entity) { - await _cmMarkLabelRep.DeleteAsync(entity); + return await _cmMarkLabelRep.DeleteAsync(entity); } [HttpGet] @@ -58,5 +82,4 @@ public class CmMarkLabelService : IDynamicApiController, ITransient .ToPageListAsync(pageObj.Index, pageObj.Size); return list; } - } \ No newline at end of file diff --git a/Cis.Application/Core/Algo/HikMarkSeacher.cs b/Cis.Application/Core/Algo/HikMarkSeacher.cs index 83e9bb9..b169e94 100644 --- a/Cis.Application/Core/Algo/HikMarkSeacher.cs +++ b/Cis.Application/Core/Algo/HikMarkSeacher.cs @@ -12,7 +12,7 @@ public class HikMarkSeacher : MarkSearcherBase protected override double ConvertPanPosToAngle(double panPos) { - double ret = (0.1 * HexToDecMa(panPos)) / (180 * Math.PI); + double ret = 0.1 * HexToDecMa(panPos) / 180 * Math.PI; ret = (ret >= 0) ? ret : (2 * Math.PI + ret); return ret; } @@ -24,7 +24,7 @@ public class HikMarkSeacher : MarkSearcherBase ndiff = HexToDecMa(tiltPos) - HexToDecMa(tiltMinPos); else ndiff = HexToDecMa(tiltPos) + HexToDecMa(13824) - HexToDecMa(tiltMinPos); - double ret = (0.1 * ndiff) / (180 * Math.PI); + double ret = 0.1 * ndiff / 180 * Math.PI; return ret; } @@ -40,8 +40,8 @@ public class HikMarkSeacher : MarkSearcherBase protected override void CalcSensor() { - _cameraCalcInfo.MinFocusX = 1783.6 / _cameraCalcInfo.ImageWidth; - _cameraCalcInfo.MinFocusY = 1781.4 / _cameraCalcInfo.ImageHeight; + _cameraCalcInfo.MinFocusX = 1783.6 / _cameraCalcInfo.VideoWidth; + _cameraCalcInfo.MinFocusY = 1781.4 / _cameraCalcInfo.VideoHeight; } #endregion Implement @@ -67,11 +67,14 @@ public class HikMarkSeacher : MarkSearcherBase return ret; } - protected double HexToDecMa(double wHex) + protected int HexToDecMa(double wHex) { - double ret = (wHex / 4096) * 1000 + ((wHex % 4096) / 256) * 100 + ((wHex % 256) / 16) * 10 + (wHex % 16); + int wHexInt = wHex.ToInt(); + int ret = (wHexInt / 4096) * 1000 + ((wHexInt % 4096) / 256) * 100 + ((wHexInt % 256) / 16) * 10 + (wHexInt % 16); return ret; } + + #endregion Util -} \ No newline at end of file +} diff --git a/Cis.Application/Core/Algo/MarkSearcherBase.cs b/Cis.Application/Core/Algo/MarkSearcherBase.cs index 1ae6d5c..b840e9c 100644 --- a/Cis.Application/Core/Algo/MarkSearcherBase.cs +++ b/Cis.Application/Core/Algo/MarkSearcherBase.cs @@ -1,4 +1,5 @@ using MathNet.Numerics.LinearAlgebra; +using MathNet.Numerics.LinearAlgebra.Double; using System.Collections.Concurrent; using System.Drawing; @@ -23,7 +24,7 @@ public abstract class MarkSearcherBase /// protected ConcurrentDictionary _markLabelInfoDict { get; set; } = new(); - protected MatrixBuilder MBuilder { get; set; } = Matrix.Build; + //protected MatrixBuilder MBuilder { get; set; } = Matrix.Build; /// /// 世界坐标转化为相机坐标矩阵 @@ -53,11 +54,11 @@ public abstract class MarkSearcherBase foreach (MarkLabelCalcInfo item in _markLabelInfoDict.Values) { Matrix labelC2WMatrix = ConvertCameraToWorld(item); - Matrix labelPointMatrix = MBuilder.DenseOfArray(new double[,] + Matrix labelPointMatrix = new DenseMatrix(3, 1, new double[] { - { item.CanvasWidth / _cameraCalcInfo.ImageWidth - 0.5 }, - { item.CanvasHeight / _cameraCalcInfo.ImageHeight - 0.5 }, - { 1 } + (item.CanvasLeftRatio * item.VideoWidth) / _cameraCalcInfo.VideoWidth - 0.5 , + (item.CanvasTopRatio * item.VideoHeight) / _cameraCalcInfo.VideoHeight - 0.5 , + 1 }); Matrix lResult = labelC2WMatrix.Multiply(labelPointMatrix); Matrix pResult = World2CameraMatrix.Multiply(lResult); @@ -68,7 +69,7 @@ public abstract class MarkSearcherBase if (x > 0.99 || x < 0.01 || y > 0.99 || y < 0.01 || pResult[2, 0] < 0) labelCalcResult = MarkLabelCalcResult.New(item.Id, false); else - labelCalcResult = MarkLabelCalcResult.New(item.Id, true, (x * _cameraCalcInfo.ImageWidth), (y * _cameraCalcInfo.ImageHeight)); + labelCalcResult = MarkLabelCalcResult.New(item.Id, true, x, y); resultList.Add(labelCalcResult); } return resultList; @@ -86,9 +87,10 @@ public abstract class MarkSearcherBase /// protected bool IsCameraRotate(PtzInfo newInfo) { - return _cameraCalcInfo.PtzInfo.Pan != newInfo.Pan || + bool ret = _cameraCalcInfo.PtzInfo.Pan != newInfo.Pan || _cameraCalcInfo.PtzInfo.Tilt != newInfo.Tilt || _cameraCalcInfo.PtzInfo.Zoom != newInfo.Zoom; + return ret; } /// @@ -106,30 +108,31 @@ public abstract class MarkSearcherBase double sinTilt = Math.Sin(tiltAngle); double cosTilt = Math.Cos(tiltAngle); - Matrix fMatrix = MBuilder.DenseOfArray(new double[,] + Matrix fMatrix = new DenseMatrix(3, 3, new double[] { - { pointF.X, 0, 0 }, - { 0, pointF.Y, 0 }, - { 0, 0, 1 }, + pointF.X, 0, 0 , + 0, pointF.Y, 0 , + 0, 0, 1 , }); - Matrix rotateTiltMatrix = MBuilder.DenseOfArray(new double[,] + Matrix rotateTiltMatrix = new DenseMatrix(3, 3, new double[] { - { 1, 0, 0 }, - { 0, cosTilt, sinTilt }, - { 0, -sinTilt, cosTilt }, + 1, 0, 0 , + 0, cosTilt, sinTilt , + 0, -sinTilt, cosTilt , }); Matrix midResult = fMatrix.Multiply(rotateTiltMatrix); - Matrix rotatePanMatrix = MBuilder.DenseOfArray(new double[,] + Matrix rotatePanMatrix = new DenseMatrix(3, 3, new double[] { - { cosPan, 0, sinPan }, - { 0, 1, 0 }, - { -sinPan, 0, cosPan }, + cosPan, 0, sinPan , + 0, 1, 0 , + -sinPan, 0, cosPan , }); - return midResult.Multiply(rotatePanMatrix); + var last = midResult.Multiply(rotatePanMatrix); + return last; } /// @@ -147,27 +150,31 @@ public abstract class MarkSearcherBase double sinTilt = Math.Sin(tiltAngle); double cosTilt = Math.Cos(tiltAngle); - Matrix rotatePanMatrix = MBuilder.DenseOfArray(new double[,] { - { cosPan, 0, -sinPan }, - { 0, 1, 0 }, - { sinPan, 0, cosPan } + Matrix rotatePanMatrix = new DenseMatrix(3, 3, new double[] + { + cosPan, 0, -sinPan , + 0, 1, 0 , + sinPan, 0, cosPan }); - Matrix rotateTiltMatrix = MBuilder.DenseOfArray(new double[,] { - { 1, 0, 0 }, - { 0, cosTilt, -sinTilt }, - { 0, sinTilt, cosTilt } + Matrix rotateTiltMatrix = new DenseMatrix(3, 3, new double[] + { + 1, 0, 0 , + 0, cosTilt, -sinTilt , + 0, sinTilt, cosTilt }); Matrix midResult = rotatePanMatrix.Multiply(rotateTiltMatrix); - Matrix fMatrix = MBuilder.DenseOfArray(new double[,] { - { (1 / pointF.X), 0, 0 }, - { 0, (1 / pointF.Y), 0 }, - { 0, 0, 1 } + Matrix fMatrix = new DenseMatrix(3, 3, new double[] + { + (1 / pointF.X), 0, 0 , + 0, (1 / pointF.Y), 0 , + 0, 0, 1 }); - return midResult.Multiply(fMatrix); + var last = midResult.Multiply(fMatrix); + return last; } /// diff --git a/Cis.Application/Core/Center/CameraDataCenter.cs b/Cis.Application/Core/Center/CameraDataCenter.cs index 5169d0f..fb20e6e 100644 --- a/Cis.Application/Core/Center/CameraDataCenter.cs +++ b/Cis.Application/Core/Center/CameraDataCenter.cs @@ -110,10 +110,10 @@ public class CameraDataCenter { long cameraId = pair.Key; MarkSearcherBase markSearcher = pair.Value; - string cameraIp = _cbCameraId2IpDict[cameraId]; - if (cameraIp == null) continue; - PtzInfo ptzInfo = _cameraPtzInfoDict[cameraIp]; - if (ptzInfo == null) continue; + bool ret = _cbCameraId2IpDict.TryGetValue(cameraId, out string cameraIp); + if (!ret) continue; + ret = _cameraPtzInfoDict.TryGetValue(cameraIp, out PtzInfo ptzInfo); + if (!ret) continue; markSearcher.UpdateCameraCalcInfo(ptzInfo); List resultList = markSearcher.Calc(); _markLabelCalcResultListDict[cameraId] = resultList; @@ -129,29 +129,25 @@ public class CameraDataCenter /// /// /// - public bool ActiveCamera(long cameraId) + public bool ActivateSearcher(long cameraId) { try { msDictLock.EnterWriteLock(); - if (_markSearcherDict.ExistsKey(cameraId)) + if (_markSearcherDict.ContainsKey(cameraId)) return false; // 获取 cbCamera CbCamera cbCamera = _cbCameraRep.GetById(cameraId); if (cbCamera == null) return false; // 获取 tbPtzCamera - TbPtzCamera tbPtzCamera; string cameraIp = cbCamera.Ip; - if (!_tbPtzCameraDict.ExistsKey(cameraIp)) + bool ret = _tbPtzCameraDict.TryGetValue(cameraIp, out TbPtzCamera tbPtzCamera); + if (!ret) { tbPtzCamera = _tbPtzCameraRep.GetFirst(u => u.Ip == cameraIp); if (tbPtzCamera == null) return false; _tbPtzCameraDict[cameraIp] = tbPtzCamera; } - else - { - tbPtzCamera = _tbPtzCameraDict[cameraIp]; - } // 存储 cbCamera id 对应 ip 关系 _cbCameraId2IpDict[cbCamera.Id] = cameraIp; // 创建 cameraCalcInfo @@ -166,10 +162,10 @@ public class CameraDataCenter MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( item.Id, PtzInfo.New(item.PanPosition, item.TiltPosition, item.ZoomPosition), - item.CanvasWidth, - item.CanvasHeight, - item.CanvasLeft, - item.CanvasTop + item.VideoWidth, + item.VideoHeight, + item.CanvasLeftRatio, + item.CanvasTopRatio ); markSeacher.AddMarkLabelCalcInfo(markLabelCalcInfo); } @@ -188,7 +184,7 @@ public class CameraDataCenter /// /// /// - public bool DeActiveCamera(long cameraId) + public bool DeActivateSearcher(long cameraId) { try { @@ -203,11 +199,16 @@ public class CameraDataCenter return true; } - public bool AddCameraMarkLabel(long cameraId, long markLabelId) + public bool IsExistSearcher(long cameraId) + { + return _markSearcherDict.ContainsKey(cameraId); + } + + public bool ActivateMarkLabel(long cameraId, long markLabelId) { - if (!_markSearcherDict.ExistsKey(cameraId)) + bool ret = _markSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); + if (!ret) return false; - MarkSearcherBase markSearcher = _markSearcherDict[cameraId]; if (markSearcher.ExistsMarkLabelCalcInfo(markLabelId)) return false; CmMarkLabel label = _cmMarkLableRep.GetById(markLabelId); @@ -216,56 +217,86 @@ public class CameraDataCenter MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( label.Id, PtzInfo.New(label.PanPosition, label.TiltPosition, label.ZoomPosition), - label.CanvasWidth, - label.CanvasHeight, - label.CanvasLeft, - label.CanvasTop + label.VideoWidth, + label.VideoHeight, + label.CanvasLeftRatio, + label.CanvasTopRatio ); return markSearcher.AddMarkLabelCalcInfo(markLabelCalcInfo); } - public bool DeleteCameraMarkLabel(long cameraId, long markLabelId) + public bool DectivateMarkLabel(long cameraId, long markLabelId) { - if (!_markSearcherDict.ExistsKey(cameraId)) - return false; - MarkSearcherBase markSearcher = _markSearcherDict[cameraId]; - return markSearcher.DeleteMarkLabelCalcInfo(markLabelId); + bool ret = _markSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); + return ret ? markSearcher.DeleteMarkLabelCalcInfo(markLabelId) : false; + } + + public bool IsExistCameraMarkLabel(long cameraId, long markLabelId) + { + bool ret = _markSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher) && + markSearcher.ExistsMarkLabelCalcInfo(markLabelId); + return ret; } public List GetMarkLabelCalcResultList(long cameraId) { - return null; + bool ret = _markLabelCalcResultListDict.TryGetValue(cameraId, out List list); + return ret ? list : new(); + } + + public PtzInfo GetCameraPtzInfo(long cameraId) + { + PtzInfo ptzInfo = null; + bool ret = _cbCameraId2IpDict.TryGetValue(cameraId,out string cameraIp) && + _cameraPtzInfoDict.TryGetValue(cameraIp, out ptzInfo); + return ret ? ptzInfo : null; + } + + public async Task ActivateSearcherAsync(long cameraId) + { + return await Task.Run(() => + { + return ActivateSearcher(cameraId); + }); + } + + public async Task DeActivateSearcherAsync(long cameraId) + { + return await Task.Run(() => + { + return DeActivateSearcher(cameraId); + }); } - public async Task ActiveCameraAsync(long cameraId) + public async Task IsExistSearcherAsync(long cameraId) { return await Task.Run(() => { - return ActiveCamera(cameraId); + return IsExistSearcher(cameraId); }); } - public async Task DeActiveCameraAsync(long cameraId) + public async Task ActivateMarkLabelAsync(long cameraId, long markLabelId) { return await Task.Run(() => { - return DeActiveCamera(cameraId); + return ActivateMarkLabel(cameraId, markLabelId); }); } - public async Task AddCameraMarkLabelAsync(long cameraId, long markLabelId) + public async Task DeactivateMarkLabelAsync(long cameraId, long markLabelId) { return await Task.Run(() => { - return AddCameraMarkLabel(cameraId, markLabelId); + return DectivateMarkLabel(cameraId, markLabelId); }); } - public async Task DeleteCameraMarkLabelAsync(long cameraId, long markLabelId) + public async Task IsExistMarkLabelAysnc(long cameraId, long markLabelId) { return await Task.Run(() => { - return DeleteCameraMarkLabel(cameraId, markLabelId); + return IsExistCameraMarkLabel(cameraId, markLabelId); }); } diff --git a/Cis.Application/Core/Entity/CameraCalcInfo.cs b/Cis.Application/Core/Entity/CameraCalcInfo.cs index f4c6bf7..11b9191 100644 --- a/Cis.Application/Core/Entity/CameraCalcInfo.cs +++ b/Cis.Application/Core/Entity/CameraCalcInfo.cs @@ -16,14 +16,14 @@ public class CameraCalcInfo public PtzInfo PtzInfo { get; set; } /// - /// 图像的宽度 + /// 视频的宽度 /// - public int ImageWidth { get; set; } = 1920; + public int VideoWidth { get; set; } = 1920; /// - /// 图像的高度 + /// 视频的高度 /// - public int ImageHeight { get; set; } = 1080; + public int VideoHeight { get; set; } = 1080; /// /// 最小焦距 @@ -40,6 +40,17 @@ public class CameraCalcInfo PtzInfo = ptzInfo }; } + + public static CameraCalcInfo New(long id, PtzInfo ptzInfo, int videoWidth, int videoHeight) + { + return new() + { + Id = id, + PtzInfo = ptzInfo, + VideoWidth = videoWidth, + VideoHeight = videoHeight + }; + } } /// @@ -89,35 +100,35 @@ public class MarkLabelCalcInfo public PtzInfo PtzInfo { get; set; } /// - /// 画布宽度 + /// 视频宽度 /// - public double CanvasWidth { get; set; } + public double VideoWidth { get; set; } /// - /// 画布高度 + /// 视频高度 /// - public double CanvasHeight { get; set; } + public double VideoHeight { get; set; } /// - /// 画布 left 距离 + /// 画布 left 距离比例 /// - public double CanvasLeft { get; set; } + public double CanvasLeftRatio { get; set; } /// - /// 画布 top 距离 + /// 画布 top 距离比例 /// - public double CanvasTop { get; set; } + public double CanvasTopRatio { get; set; } - public static MarkLabelCalcInfo New(long id, PtzInfo ptzInfo, double canvasWidth, double canvasHeight, double canvasLeft, double canvasTop) + public static MarkLabelCalcInfo New(long id, PtzInfo ptzInfo, double videoWidth, double videoHeight, double canvasLeftRatio, double canvasTopRatio) { return new() { Id = id, PtzInfo = ptzInfo, - CanvasWidth = canvasWidth, - CanvasHeight = canvasHeight, - CanvasLeft = canvasLeft, - CanvasTop = canvasTop + VideoWidth = videoWidth, + VideoHeight = videoHeight, + CanvasLeftRatio = canvasLeftRatio, + CanvasTopRatio = canvasTopRatio }; } } @@ -139,14 +150,14 @@ public class MarkLabelCalcResult public bool InFlag { get; set; } /// - /// 画布 left 距离 + /// 画布 left 距离比例 /// - public double CanvasLeft { get; set; } + public double CanvasLeftRatio { get; set; } /// - /// 画布 top 距离 + /// 画布 top 距离比例 /// - public double CanvasTop { get; set; } + public double CanvasTopRatio { get; set; } public static MarkLabelCalcResult New(long id, bool inFlag) { @@ -157,14 +168,14 @@ public class MarkLabelCalcResult }; } - public static MarkLabelCalcResult New(long id, bool inFlag, double canvasLeft, double canvasTop) + public static MarkLabelCalcResult New(long id, bool inFlag, double canvasLeftRatio, double canvasTopRatio) { return new() { Id = id, InFlag = inFlag, - CanvasLeft = canvasLeft, - CanvasTop = canvasTop + CanvasLeftRatio = canvasLeftRatio, + CanvasTopRatio = canvasTopRatio }; } } \ No newline at end of file diff --git a/Cis.Application/Core/Service/MarkSearchService.cs b/Cis.Application/Core/Service/MarkSearchService.cs index 5e1105d..47654d9 100644 --- a/Cis.Application/Core/Service/MarkSearchService.cs +++ b/Cis.Application/Core/Service/MarkSearchService.cs @@ -17,27 +17,39 @@ public class MarkSearchService : IDynamicApiController, ITransient } [HttpPost] - public async Task ActivateCamera(long cameraId) + public async Task ActivateSearcher([FromForm] long cameraId) { - return await _cameraDataCenter.ActiveCameraAsync(cameraId); + return await _cameraDataCenter.ActivateSearcherAsync(cameraId); } [HttpPost] - public async Task DeActiveCamera(long cameraId) + public async Task DeActivateSearcher([FromForm] long cameraId) { - return await _cameraDataCenter.DeActiveCameraAsync(cameraId); + return await _cameraDataCenter.DeActivateSearcherAsync(cameraId); + } + + [HttpGet] + public async Task IsExistSearcher(long cameraId) + { + return await _cameraDataCenter.IsExistSearcherAsync(cameraId); } [HttpPost] - public async Task AddCameraMarkLabel(long cameraId, long markLabelId) + public async Task ActivateMarkLabel([FromForm] long cameraId, [FromForm] long markLabelId) { - return await _cameraDataCenter.AddCameraMarkLabelAsync(cameraId, markLabelId); + return await _cameraDataCenter.ActivateMarkLabelAsync(cameraId, markLabelId); } [HttpPost] - public async Task DeleteCameraMarkLabel(long cameraId, long markLabelId) + public async Task DeactivateMarkLabel([FromForm] long cameraId, [FromForm] long markLabelId) + { + return await _cameraDataCenter.DeactivateMarkLabelAsync(cameraId, markLabelId); + } + + [HttpGet] + public async Task IsExistMarkLabel(long cameraId,long markLabelId) { - return await _cameraDataCenter.DeleteCameraMarkLabelAsync(cameraId, markLabelId); + return await _cameraDataCenter.IsExistMarkLabelAysnc(cameraId, markLabelId); } [HttpGet] diff --git a/Cis.Application/Startup.cs b/Cis.Application/Startup.cs index 43c51e4..167af63 100644 --- a/Cis.Application/Startup.cs +++ b/Cis.Application/Startup.cs @@ -14,7 +14,7 @@ public class Startup : AppStartup /// public void ConfigureServices(IServiceCollection services) { - services.AddConfigurableOptions(); + services.AddConfigurableOptions(); services.AddConfigurableOptions(); services.AddSingleton(new CameraDataCenter()); diff --git a/Cis.Application/Sys/Service/SysDictDataService.cs b/Cis.Application/Sys/Service/SysDictDataService.cs index 2f757d4..ccf6223 100644 --- a/Cis.Application/Sys/Service/SysDictDataService.cs +++ b/Cis.Application/Sys/Service/SysDictDataService.cs @@ -16,21 +16,21 @@ public class SysDictDataService : IDynamicApiController, ITransient } [HttpPost] - public async Task Add(SysDictData entity) + public async Task Add([FromForm] SysDictData entity) { - await _sysDictDataRep.InsertAsync(entity); + return await _sysDictDataRep.InsertAsync(entity); } [HttpPost] - public async Task Update(SysDictData entity) + public async Task Update([FromForm] SysDictData entity) { - await _sysDictDataRep.UpdateAsync(entity); + return await _sysDictDataRep.UpdateAsync(entity); } [HttpPost] - public async Task Delete(SysDictData entity) + public async Task Delete([FromForm] SysDictData entity) { - await _sysDictDataRep.DeleteAsync(entity); + return await _sysDictDataRep.DeleteAsync(entity); } [HttpGet] diff --git a/Cis.Application/Sys/Service/SysDictTypeService.cs b/Cis.Application/Sys/Service/SysDictTypeService.cs index 31165d7..d3805a3 100644 --- a/Cis.Application/Sys/Service/SysDictTypeService.cs +++ b/Cis.Application/Sys/Service/SysDictTypeService.cs @@ -17,21 +17,21 @@ public class SysDictTypeService : IDynamicApiController, ITransient } [HttpPost] - public async Task Add(SysDictType entity) + public async Task Add([FromForm] SysDictType entity) { - await _sysDictTypeRep.InsertAsync(entity); + return await _sysDictTypeRep.InsertAsync(entity); } [HttpPost] - public async Task Update(SysDictType entity) + public async Task Update([FromForm] SysDictType entity) { - await _sysDictTypeRep.UpdateAsync(entity); + return await _sysDictTypeRep.UpdateAsync(entity); } [HttpPost] - public async Task Delete(SysDictType entity) + public async Task Delete([FromForm] SysDictType entity) { - await _sysDictTypeRep.DeleteAsync(entity); + return await _sysDictTypeRep.DeleteAsync(entity); } [HttpGet] diff --git a/Cis.Application/Tb/Service/TbPtzCameraService.cs b/Cis.Application/Tb/Service/TbPtzCameraService.cs index 58d0f2d..bf69a64 100644 --- a/Cis.Application/Tb/Service/TbPtzCameraService.cs +++ b/Cis.Application/Tb/Service/TbPtzCameraService.cs @@ -12,21 +12,21 @@ public class TbPtzCameraService : ITransient } [HttpPost] - public async Task Add(TbPtzCamera entity) + public async Task Add([FromForm] TbPtzCamera entity) { - await _tbPtzCameraRep.InsertAsync(entity); + return await _tbPtzCameraRep.InsertAsync(entity); } [HttpPost] - public async Task Update(TbPtzCamera entity) + public async Task Update([FromForm] TbPtzCamera entity) { - await _tbPtzCameraRep.UpdateAsync(entity); + return await _tbPtzCameraRep.UpdateAsync(entity); } [HttpPost] - public async Task Delete(TbPtzCamera entity) + public async Task Delete([FromForm] TbPtzCamera entity) { - await _tbPtzCameraRep.DeleteAsync(entity); + return await _tbPtzCameraRep.DeleteAsync(entity); } [HttpGet]