From 2000b36f214b2c8edcec0d812e30a6db85a46482 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期五, 17 五月 2024 14:33:28 +0800
Subject: [PATCH] 添加videoLabel 转发
---
vo/videoLabel.go | 22 +++++++++++
controller/captureCtl.go | 55 +++++++++++++++++++++++++++
routes/capture.go | 1
3 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/controller/captureCtl.go b/controller/captureCtl.go
index 80ceb91..223dec0 100644
--- a/controller/captureCtl.go
+++ b/controller/captureCtl.go
@@ -65,3 +65,58 @@
c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
}
+func (a CaptureController) VideoLabels(c *gin.Context) {
+ var req vo.RequestVideoLabelList
+ if err := c.BindJSON(&req); err != nil {
+ c.AbortWithStatus(http.StatusBadRequest)
+ return
+ }
+
+ if len(req.VideoLabelListObject.VideoLabelObject) == 0 {
+ c.AbortWithStatus(http.StatusBadRequest)
+ return
+ }
+
+ videoLabel := req.VideoLabelListObject.VideoLabelObject[0]
+ logger.Debug("Receive new message, Id:%s Ip:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), videoLabel.VideoLabelID)
+
+ // 杞汉鑴告秷鎭�
+ var face vo.FaceObject
+ face.FaceID = videoLabel.VideoLabelID
+ face.InfoKind = 1
+ face.SourceID = videoLabel.VideoImageID
+ face.SourceID = videoLabel.VideoImageID
+ face.LocationMarkTime = videoLabel.CreateTimeAbs
+ face.FaceAppearTime = videoLabel.BehaviorAnalysisObject.BehaviorBeginTime
+ face.FaceDisAppearTime = videoLabel.BehaviorAnalysisObject.BehaviorEndTime
+
+ for idx, _ := range videoLabel.SubImageList.SubImageInfoObject {
+ videoLabel.SubImageList.SubImageInfoObject[idx].EventSort = 10
+ }
+
+ face.SubImageList.SubImageInfoObject = videoLabel.SubImageList.SubImageInfoObject
+
+ // 濡傛灉寮�鍚簡涓嬬骇, 韬唤搴旇鏄秷鎭唬鐞�, 涓嶅啀杞彂鍒版湇鍔″櫒
+ if config.ClientConf.Enable && config.ServeConf.Role == "agent" {
+ //go a.Repository.VIIDMsgForward(&req)
+ } else if config.ServeConf.Role == "cascade" {
+ go service.AddFaceNotification(&face)
+ }
+
+ if config.ForwardConf.SyncServer != "" {
+ go a.Repository.FaceForward([]vo.FaceObject{face})
+ }
+
+ // 璁惧淇濇椿
+ service.KeepDeviceAlive(videoLabel.IVADeviceID)
+
+ rspMsg := vo.ResponseStatus{
+ RequestURL: c.FullPath(),
+ StatusCode: vo.StatusSuccess,
+ StatusString: vo.StatusString[vo.StatusSuccess],
+ Id: videoLabel.VideoLabelID,
+ LocalTime: time.Now().Format("20060102150405"),
+ }
+
+ c.JSON(http.StatusOK, gin.H{"ResponseStatusObject": rspMsg})
+}
diff --git a/routes/capture.go b/routes/capture.go
index 898f0ed..7cb31e0 100644
--- a/routes/capture.go
+++ b/routes/capture.go
@@ -12,6 +12,7 @@
// 鎵归噺浜鸿劯鏂板
r.POST("/Faces", capCtl.Faces)
+ r.POST("/VideoLabels", capCtl.VideoLabels)
return r
}
diff --git a/vo/videoLabel.go b/vo/videoLabel.go
new file mode 100644
index 0000000..6ac9898
--- /dev/null
+++ b/vo/videoLabel.go
@@ -0,0 +1,22 @@
+package vo
+
+type RequestVideoLabelList struct {
+ VideoLabelListObject struct {
+ VideoLabelObject []VideoLabelObject `json:"VideoLabelObject"`
+ } `json:"VideoLabelListObject"`
+}
+
+type VideoLabelObject struct {
+ VideoLabelID string `json:"VideoLabelID"`
+ EventSort int `json:"EventSort"`
+ VideoImageID string `json:"VideoImageID"`
+ IVADeviceID string `json:"IVADeviceID"`
+ CreateTimeAbs string `json:"CreateTimeAbs"`
+ BehaviorAnalysisObject struct {
+ BehaviorBeginTime string
+ BehaviorEndTime string
+ } `json:"BehaviorAnalysisObject"`
+ SubImageList struct {
+ SubImageInfoObject []SubImageInfoObject
+ } `json:"SubImageList"`
+}
--
Gitblit v1.8.0