|
|
@ -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<MarkLabelCalcResult> resultList = markSearcher.Calc(); |
|
|
|
_markLabelCalcResultListDict[cameraId] = resultList; |
|
|
@ -129,29 +129,25 @@ public class CameraDataCenter |
|
|
|
/// </summary>
|
|
|
|
/// <param name="cameraId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
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 |
|
|
|
/// </summary>
|
|
|
|
/// <param name="cameraId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
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<MarkLabelCalcResult> GetMarkLabelCalcResultList(long cameraId) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
bool ret = _markLabelCalcResultListDict.TryGetValue(cameraId, out List<MarkLabelCalcResult> 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<bool> ActivateSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return ActivateSearcher(cameraId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> DeActivateSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return DeActivateSearcher(cameraId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> ActiveCameraAsync(long cameraId) |
|
|
|
public async Task<bool> IsExistSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return ActiveCamera(cameraId); |
|
|
|
return IsExistSearcher(cameraId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> DeActiveCameraAsync(long cameraId) |
|
|
|
public async Task<bool> ActivateMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return DeActiveCamera(cameraId); |
|
|
|
return ActivateMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> AddCameraMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
public async Task<bool> DeactivateMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return AddCameraMarkLabel(cameraId, markLabelId); |
|
|
|
return DectivateMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> DeleteCameraMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
public async Task<bool> IsExistMarkLabelAysnc(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return DeleteCameraMarkLabel(cameraId, markLabelId); |
|
|
|
return IsExistCameraMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|