| | |
| | | |
| | | type AlarmRule struct { |
| | | GroupId string `json:"groupId"` |
| | | AlarmLevel string `json:"alarmLevel"` |
| | | AlarmLevel int32 `json:"alarmLevel"` |
| | | RuleText string `json:"ruleText"` |
| | | } |
| | | |
| | |
| | | faceParam := protomsg.ParamFacePos{} |
| | | err1 := proto.Unmarshal(sdkinfo.Sdkdata, &faceParam) |
| | | if err1 != nil { |
| | | fmt.Println("解析sdk数据时出现错误", err1) |
| | | fmt.Println("解析FACE sdk数据时出现错误", err1) |
| | | continue |
| | | } |
| | | for _, face := range faceParam.Faces { |
| | |
| | | yoloObj := protomsg.ParamYoloObj{} |
| | | err1 := proto.Unmarshal(sdkinfo.Sdkdata, &yoloObj) |
| | | if err1 != nil { |
| | | fmt.Println("解析sdk数据时出现错误", err1) |
| | | fmt.Println("解析YOLO sdk数据时出现错误", err1) |
| | | continue |
| | | } |
| | | alarmRules := []AlarmRule{} |
| | |
| | | return |
| | | |
| | | } |
| | | err = EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody) |
| | | err = EsReq("POST", "http://192.168.1.182:9200/personaction/perVideoAction", requstbody) |
| | | if err != nil { |
| | | fmt.Println("es can not execute right.") |
| | | } |
| | |
| | | ruleserver.MainJudge(&arg) |
| | | // 把arg里的打的标签拿出来给m再封装一层 |
| | | resultMag := ruleserver.ResultMsg{SdkMessage: m, RuleResult: arg.RuleResult} |
| | | fmt.Println("打完标签后的结果:",resultMag) |
| | | //fmt.Println("打完标签后的结果:",resultMag) |
| | | |
| | | // 将打完标签的数据插入到ES |
| | | insertdata.InsertToEs(resultMag) |
| | |
| | | yoloParam := protomsg.ParamYoloObj{} |
| | | err = proto.Unmarshal(sdkinfo.Sdkdata, &yoloParam) |
| | | if err != nil { |
| | | fmt.Println("解析sdk数据时出现错误", err) |
| | | fmt.Println("解析FACE sdk数据时出现错误", err) |
| | | continue |
| | | } |
| | | for _, info := range yoloParam.Infos { |
| | |
| | | faceParam := protomsg.ParamFacePos{} |
| | | err = proto.Unmarshal(sdkinfo.Sdkdata, &faceParam) |
| | | if err != nil { |
| | | fmt.Println("解析sdk数据时出现错误", err) |
| | | fmt.Println("解析YOLO sdk数据时出现错误", err) |
| | | continue |
| | | } |
| | | for _, info := range faceParam.Faces { |
| | | photoMap := ruleserver.PhotoMap{Rects:nil, Score: float64(info.Pos.Quality)} |
| | | photoMap := ruleserver.PhotoMap{Rects:ruleserver.Rect{}, Score: float64(info.Pos.Quality)} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | } |
| | |
| | | filterRule(groupRule.Rules[j], &areaMap) |
| | | } |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | // 再过其他数据 这步直接得到结果(真或假) |
| | | // 再过其他数据 这步直接得到结果(真或假) 过目标数量 |
| | | flag := transferParameters(groupRule.Rules[j], &areaMap) |
| | | if flag != "" { |
| | | fmt.Println("得出的结果", flag) |
| | | completeFormula = completeFormula + groupRule.Rules[j].RuleWithPre + "" + flag |
| | | } |
| | | } |
| | | if completeFormula == "" { |
| | | flag := splice1(&areaMap) |
| | | if flag != "" { |
| | | fmt.Println("强行拼凑一个人数是否大于0的结果", flag) |
| | | completeFormula = completeFormula + groupRule.Rules[j].RuleWithPre + "" + flag |
| | | } |
| | | |
| | | } |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | // 这步过的是时间规则(时间段等) |
| | | flag := timeRuleResult(groupRule.Rules[j], &areaMap) |
| | |
| | | completeFormula = completeFormula + groupRule.Rules[j].RuleWithPre + "" + flag |
| | | } |
| | | } |
| | | |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | // 最后过持续时间等时间维度的条件 |
| | | duration(groupRule.Rules[j], &areaMap) |
| | | } |
| | | |
| | | } |
| | | fmt.Println("拼出的数学公式为:==== ", completeFormula) |
| | | if completeFormula != "" { |
| | |
| | | formula = strconv.FormatFloat(arg.size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | } |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | if result.(bool) { |
| | | am.filterData = append(am.filterData, arg) // 得到符合条件的过滤数据 |
| | | } |
| | | } |
| | | am.targetNum = len(am.filterData) // 把符合条件的目标数量更新到targetNum字段 |
| | | //fmt.Println("筛选完后的内容:", am) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 冗余拼接 |
| | | func splice1 (am *AreaMap) string { |
| | | args := am.targetNum |
| | | formula := strconv.Itoa(args) + " " + ">" + "0" |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | return strconv.FormatBool(result.(bool)) |
| | | } |
| | | // 给数据库的规则表达式代参 args: 一条子规则,区域数据 |
| | | func transferParameters(rule *protomsg.Rule, am *AreaMap) string { |
| | | if rule.PolygonId == am.areaId { // 首先规则所对应的区域id要跟区域数据的id对的上 |
| | |
| | | } else { |
| | | return "false" |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | uuid "github.com/satori/go.uuid" |
| | | "io" |
| | | "log" |
| | | "mime/multipart" |
| | |
| | | "time" |
| | | ) |
| | | var weedfsUri = "http://192.168.1.182:9500/submit" |
| | | func PostFormData(uri string, filename, paramName string, file multipart.File) (maps map[string]interface{}, err0 error) { |
| | | func PostFormData(uri string) (maps map[string]interface{}, err0 error) { |
| | | body := &bytes.Buffer{} |
| | | writer := multipart.NewWriter(body) |
| | | _, err := writer.CreateFormFile(paramName, filename) |
| | | _, err := writer.CreateFormFile("file", uuid.NewV4().String()) |
| | | if err != nil { |
| | | return nil, err |
| | | } |