package util import ( "basic.com/pubsub/protomsg.git" ) type BaseCompareInfo struct { TableId string `json:"tableId"` TableName string `json:"tableName"` BwType string `json:"bwType"` CompareScore float64 `json:"compareScore"` TargetId string `json:"targetId"` TargetName string `json:"targetName"` TargetPicUrl string `json:"targetPicUrl"` MonitorLevel string `json:"monitorLevel"` Content string `json:"content"` DbLabel string `json:"labels"` } type AlarmRule struct { GroupId string `json:"groupId"` AlarmLevel string `json:"alarmLevel"` RuleText string `json:"ruleText"` DefenceState bool `json:"defenceState"` LinkInfo string `json:"linkInfo"` } type Point struct { X float64 `json:"x"` Y float64 `json:"y"` } type Points struct { TopLeft Point `json:"topLeft"` BottomRight Point `json:"bottomRight"` } type TargetInfo struct { TargetId string `json:"targetId"` AreaId string `json:"areaId"` AreaName string `json:"areaName"` TargetScore float64 `json:"targetScore"` TargetType string `json:"targetType"` Feature string `json:"feature"` PicSmUrl string `json:"picSmUrl"` TargetLocation Points `json:"targetLocation"` BelongsTargetID string `json:"belongsTargetId"` Attribute string `json:"attribute"` } //type Target struct { // TargetInfo // AttachTarget TargetInfo `json:"attachTarget"` //} //type GroupRuleResult struct { // AlarmRules AlarmRule `json:"alarmRules"` // PicDate string `json:"picDate"` // PicMaxUrl string `json:"picMaxUrl"` //} type PicWidHei struct { PicW int `json:"picW"` PicH int `json:"picH"` } type TaskResultInfo struct { Id string `json:"id"` CameraId string `json:"cameraId"` CameraAddr string `json:"cameraAddr"` CameraName string `json:"cameraName"` PicDate string `json:"picDate"` PicId int64 `json:"picId"` PicMaxUrl []string `json:"picMaxUrl"` PicWH PicWidHei `json:"picWH"` TaskId string `json:"taskId"` TaskName string `json:"taskName"` SdkName string `json:"sdkName"` Content string `json:"content"` AlarmRules []AlarmRule `json:"alarmRules"` LikeDate string `json:"likeDate"` ShowLabels string `json:"showLabels"` OtherLabels string `json:"otherLabels"` VideoUrl string `json:"videoUrl"` AnalyServerId string `json:"analyServerId"` AnalyServerName string `json:"analyServerName"` AnalyServerIp string `json:"analyServerIp"` ClusterId string `json:"clusterId"` IsAlarm bool `json:"isAlarm"` IsAckAlarm bool `json:"isAckAlarm"` IsCollect bool `json:"isCollect"` IsDelete bool `json:"isDelete"` BaseInfo []*BaseCompareInfo `json:"baseInfo"` TargetInfo []TargetInfo `json:"targetInfo"` FileId string `json:"fileId"` // 数据栈文件id DataSource string `json:"dataSource"` // 数据来源:摄像机, 数据栈 } // 统一的数据结构 type ESInfo struct { TaskResultInfo Version string `json:"version"` UpdateTime string `json:"updateTime"` LinkTag string `json:"linkTag"` LinkTagInfo []*TaskResultInfo `json:"linkTagInfo"` } ////so处理后的target //type SoTarget struct { // SrcTarget protomsg.Target // BelongsTargetID string //} type TaskBasicInfo struct { CamId string CamName string TaskID string TaskName string HandleTime string ImageId int64 ImageTime string IsEndRecord bool FileId string // 数据栈中的文件id } //缓存数据信息 type CacheInfo struct { TBI TaskBasicInfo RuleGroup *protomsg.GroupRule IsAlarm bool AlarmResult *SOResult Image *protomsg.Image } //SO处理后的结果 //做目标检测的(如人脸检测)IsEvent==false,且需要和底库比对,需要分成多个SOResult,每个SOResult包含一个AlarmTargets,可能多个CompDbinfo //做目标检测的(如人脸检测)IsEvent==false,但不需要和底库比对,也需要分成多个SOResult,每个SOResult包含一个AlarmTargets,只是没有CompDbinfo //不是目标检测IsEvent==true,不需要和底库比对,就只返回一个SOResult,可能包含多个AlarmTargets,但是没有CompDbinfo type SOResult struct { IsEvent bool IsEndRecord bool Targets []SoTarget FirstImage *protomsg.Image CacheImage *protomsg.Image SoRule *SoRule GroupRule *protomsg.GroupRule SoType string } type SoTarget struct { SrcTarget protomsg.Target AreaId string AreaName string BelongsTargetID string CompDbInfo []*BaseCompareInfo ImageId int64 } type EventCache struct { Targets map[uint64]*SoTarget RuleGroups map[string]*protomsg.GroupRule Images map[int64]*protomsg.Image } type TargetCache struct { Target *SoTarget RuleGroups map[string]*protomsg.GroupRule Image *protomsg.Image } type RuleMessage struct { BaseInfo TaskBasicInfo Events map[string]EventCache Targets map[string]TargetCache } type RuleParams struct { SdkArgAlias string Operator string OperatorType string SdkArgValue string } type SoRule struct { Id string CameraId string PolygonId string SdkId string Sort int32 RuleWithPre string IsSaveAnyhow bool GroupId string Params []RuleParams } var AlarmLevelMap = map[int32]string{ 0: "撤防", 1: "一级", 2: "二级", 3: "三级", 4: "四级", 5: "五级", 6: "撤防", } func ParamRestrict(src, min, max, def int32) int32 { if min <= src && src <= max { return src } return def }