|
@ -110,10 +110,10 @@ public class CameraDataCenter |
|
|
{ |
|
|
{ |
|
|
long cameraId = pair.Key; |
|
|
long cameraId = pair.Key; |
|
|
MarkSearcherBase markSearcher = pair.Value; |
|
|
MarkSearcherBase markSearcher = pair.Value; |
|
|
string cameraIp = _cbCameraId2IpDict[cameraId]; |
|
|
bool ret = _cbCameraId2IpDict.TryGetValue(cameraId, out string cameraIp); |
|
|
if (cameraIp == null) continue; |
|
|
if (!ret) continue; |
|
|
PtzInfo ptzInfo = _cameraPtzInfoDict[cameraIp]; |
|
|
ret = _cameraPtzInfoDict.TryGetValue(cameraIp, out PtzInfo ptzInfo); |
|
|
if (ptzInfo == null) continue; |
|
|
if (!ret) continue; |
|
|
markSearcher.UpdateCameraCalcInfo(ptzInfo); |
|
|
markSearcher.UpdateCameraCalcInfo(ptzInfo); |
|
|
List<MarkLabelCalcResult> resultList = markSearcher.Calc(); |
|
|
List<MarkLabelCalcResult> resultList = markSearcher.Calc(); |
|
|
_markLabelCalcResultListDict[cameraId] = resultList; |
|
|
_markLabelCalcResultListDict[cameraId] = resultList; |
|
@ -129,29 +129,25 @@ public class CameraDataCenter |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="cameraId"></param>
|
|
|
/// <param name="cameraId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public bool ActiveCamera(long cameraId) |
|
|
public bool ActivateSearcher(long cameraId) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
msDictLock.EnterWriteLock(); |
|
|
msDictLock.EnterWriteLock(); |
|
|
if (_markSearcherDict.ExistsKey(cameraId)) |
|
|
if (_markSearcherDict.ContainsKey(cameraId)) |
|
|
return false; |
|
|
return false; |
|
|
// 获取 cbCamera
|
|
|
// 获取 cbCamera
|
|
|
CbCamera cbCamera = _cbCameraRep.GetById(cameraId); |
|
|
CbCamera cbCamera = _cbCameraRep.GetById(cameraId); |
|
|
if (cbCamera == null) return false; |
|
|
if (cbCamera == null) return false; |
|
|
// 获取 tbPtzCamera
|
|
|
// 获取 tbPtzCamera
|
|
|
TbPtzCamera tbPtzCamera; |
|
|
|
|
|
string cameraIp = cbCamera.Ip; |
|
|
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); |
|
|
tbPtzCamera = _tbPtzCameraRep.GetFirst(u => u.Ip == cameraIp); |
|
|
if (tbPtzCamera == null) return false; |
|
|
if (tbPtzCamera == null) return false; |
|
|
_tbPtzCameraDict[cameraIp] = tbPtzCamera; |
|
|
_tbPtzCameraDict[cameraIp] = tbPtzCamera; |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
tbPtzCamera = _tbPtzCameraDict[cameraIp]; |
|
|
|
|
|
} |
|
|
|
|
|
// 存储 cbCamera id 对应 ip 关系
|
|
|
// 存储 cbCamera id 对应 ip 关系
|
|
|
_cbCameraId2IpDict[cbCamera.Id] = cameraIp; |
|
|
_cbCameraId2IpDict[cbCamera.Id] = cameraIp; |
|
|
// 创建 cameraCalcInfo
|
|
|
// 创建 cameraCalcInfo
|
|
@ -166,10 +162,10 @@ public class CameraDataCenter |
|
|
MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( |
|
|
MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( |
|
|
item.Id, |
|
|
item.Id, |
|
|
PtzInfo.New(item.PanPosition, item.TiltPosition, item.ZoomPosition), |
|
|
PtzInfo.New(item.PanPosition, item.TiltPosition, item.ZoomPosition), |
|
|
item.CanvasWidth, |
|
|
item.VideoWidth, |
|
|
item.CanvasHeight, |
|
|
item.VideoHeight, |
|
|
item.CanvasLeft, |
|
|
item.CanvasLeftRatio, |
|
|
item.CanvasTop |
|
|
item.CanvasTopRatio |
|
|
); |
|
|
); |
|
|
markSeacher.AddMarkLabelCalcInfo(markLabelCalcInfo); |
|
|
markSeacher.AddMarkLabelCalcInfo(markLabelCalcInfo); |
|
|
} |
|
|
} |
|
@ -188,7 +184,7 @@ public class CameraDataCenter |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="cameraId"></param>
|
|
|
/// <param name="cameraId"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public bool DeActiveCamera(long cameraId) |
|
|
public bool DeActivateSearcher(long cameraId) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -203,11 +199,16 @@ public class CameraDataCenter |
|
|
return true; |
|
|
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; |
|
|
return false; |
|
|
MarkSearcherBase markSearcher = _markSearcherDict[cameraId]; |
|
|
|
|
|
if (markSearcher.ExistsMarkLabelCalcInfo(markLabelId)) |
|
|
if (markSearcher.ExistsMarkLabelCalcInfo(markLabelId)) |
|
|
return false; |
|
|
return false; |
|
|
CmMarkLabel label = _cmMarkLableRep.GetById(markLabelId); |
|
|
CmMarkLabel label = _cmMarkLableRep.GetById(markLabelId); |
|
@ -216,56 +217,86 @@ public class CameraDataCenter |
|
|
MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( |
|
|
MarkLabelCalcInfo markLabelCalcInfo = MarkLabelCalcInfo.New( |
|
|
label.Id, |
|
|
label.Id, |
|
|
PtzInfo.New(label.PanPosition, label.TiltPosition, label.ZoomPosition), |
|
|
PtzInfo.New(label.PanPosition, label.TiltPosition, label.ZoomPosition), |
|
|
label.CanvasWidth, |
|
|
label.VideoWidth, |
|
|
label.CanvasHeight, |
|
|
label.VideoHeight, |
|
|
label.CanvasLeft, |
|
|
label.CanvasLeftRatio, |
|
|
label.CanvasTop |
|
|
label.CanvasTopRatio |
|
|
); |
|
|
); |
|
|
return markSearcher.AddMarkLabelCalcInfo(markLabelCalcInfo); |
|
|
return markSearcher.AddMarkLabelCalcInfo(markLabelCalcInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public bool DeleteCameraMarkLabel(long cameraId, long markLabelId) |
|
|
public bool DectivateMarkLabel(long cameraId, long markLabelId) |
|
|
{ |
|
|
{ |
|
|
if (!_markSearcherDict.ExistsKey(cameraId)) |
|
|
bool ret = _markSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); |
|
|
return false; |
|
|
return ret ? markSearcher.DeleteMarkLabelCalcInfo(markLabelId) : false; |
|
|
MarkSearcherBase markSearcher = _markSearcherDict[cameraId]; |
|
|
} |
|
|
return markSearcher.DeleteMarkLabelCalcInfo(markLabelId); |
|
|
|
|
|
|
|
|
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) |
|
|
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 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 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 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 await Task.Run(() => |
|
|
{ |
|
|
{ |
|
|
return DeleteCameraMarkLabel(cameraId, markLabelId); |
|
|
return IsExistCameraMarkLabel(cameraId, markLabelId); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|