| | |
| | | package ruleserver |
| | | |
| | | import ( |
| | | "basic.com/valib/logger.git" |
| | | "plugin" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/logger" |
| | | "ruleprocess/structure" |
| | | "sort" |
| | | "strconv" |
| | |
| | | |
| | | // 对单帧图像的判断 thisSdkDatas 当前传入的这帧数据,cacheSdkData 定时器里缓存的一帧数据 没有就返回nil (thisSdkDatas SdkDatas, cacheSdkDatas SdkDatas) |
| | | func Judge(args *structure.SdkDatas, message *protomsg.SdkMessage) { |
| | | defer func() { |
| | | if err := recover(); err != nil { |
| | | logger.Error("规则模块儿的异常捕获:",err) |
| | | } |
| | | }() |
| | | if len(args.Sdkdata) > 0 { |
| | | // 拿到本摄像机的区域 |
| | | cameraPolygons := GetPolygons(args.CameraId) |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func CallSo(sdkId string,rule *protomsg.Rule, am *structure.AreaMap) structure.LittleRuleResult{ |
| | | // 根据sdkId查出其对应的sdk的soName,调用相应so的Entrance方法 |
| | | var soName = "" |
| | | if sdkId == "812b674b-2375-4589-919a-5c1c3278a97e" { |
| | | soName = "face.so" |
| | | } else if sdkId == "812b674b-2375-4589-919a-5c1c3278a975"{ |
| | | soName = "intrusion.so" |
| | | } else if sdkId == "812b674b-2375-4589-919a-5c1c3278a976" { |
| | | soName = "personUnsual.so" |
| | | } else if sdkId == "812b674b-2375-4589-919a-5c1c3278a972" { |
| | | soName = "faceCompare.so" |
| | | } |
| | | p,err := plugin.Open("./algorithm/"+soName) |
| | | if err != nil { |
| | | panic(err) |
| | | } |
| | | f,err1 := p.Lookup("Entrance") |
| | | if err1 != nil { |
| | | panic("没有找到入口函数") |
| | | } |
| | | ruleResult := f.(func(rule *protomsg.Rule, am *structure.AreaMap)structure.LittleRuleResult)(rule,am) |
| | | return ruleResult |
| | | } |
| | | |
| | | func CallMiddleware(args *structure.SdkDatas,rule protomsg.GroupRule) ([]*structure.LittleRuleResult, string, string){ |
| | |
| | | //} |
| | | logger.Warn("___________________________________________________________________________终于走完万里长征") |
| | | // 把他们的位置数据也传下去 |
| | | locations := []structure.Rect{} |
| | | locations := []structure.TargetInfo{} |
| | | for _, sdkData := range args.Sdkdata { |
| | | if sdkData.IpcId == "02D54B61-0F16-C604-8567-FC4BE493C523" && sdkNames != "" { // 把yolo数据的各个目标的坐标输出方便后面画框 |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | |
| | | //logger.Info("-------------------yolo结果标签长度", len(args.RuleResult["yolo"].([]Result))) |
| | | } |
| | | if faceFlag { |
| | | args.RuleResult["face"] = append(args.RuleResult["face"].([]structure.FaceResult), structure.FaceResult{structure.Result{taskId, sdkNames, groupRule.GroupId, groupRule.DefenceState, groupRule.AlarmLevel, groupRule.GroupText, []structure.Rect{}, polygonId, islink, label,}, faces}) |
| | | args.RuleResult["face"] = append(args.RuleResult["face"].([]structure.FaceResult), structure.FaceResult{structure.Result{taskId, sdkNames, groupRule.GroupId, groupRule.DefenceState, groupRule.AlarmLevel, groupRule.GroupText, []structure.TargetInfo{}, polygonId, islink, label,}, faces}) |
| | | //logger.Info("-------------------face结果标签", len(args.RuleResult["face"].([]FaceResult))) |
| | | labelTypes = append(labelTypes,1) |
| | | } |
| | |
| | | return faces |
| | | } |
| | | |
| | | func putYolosToResult(am *structure.AreaMap) []structure.Rect { |
| | | locations := []structure.Rect{} |
| | | func putYolosToResult(am *structure.AreaMap) []structure.TargetInfo { |
| | | locations := []structure.TargetInfo{} |
| | | if len(am.FilterData) > 0 { |
| | | for _, data := range am.FilterData { |
| | | locations = append(locations, data.Location) |
| | | location := structure.TargetInfo{} |
| | | location.Rect = data.Location |
| | | location.TargetId = data.Id |
| | | location.TargetScore = data.Score |
| | | locations = append(locations, location) |
| | | } |
| | | } |
| | | //logger.Println("-----------------------------------------------听说你是空的?",faces) |