| | |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "io/ioutil" |
| | | "net" |
| | | "ruleprocess/cache" |
| | | "basic.com/valib/logger.git" |
| | | "ruleprocess/logger" |
| | | "strconv" |
| | | "time" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "github.com/go-yaml/yaml" |
| | | "github.com/golang/protobuf/proto" |
| | | "github.com/satori/go.uuid" |
| | | "ruleprocess/ruleserver" |
| | |
| | | DbTablePersons string `yaml:"dbTablePersons"` |
| | | } |
| | | |
| | | func init() { |
| | | data, err := ioutil.ReadFile("./config/conf.yml") |
| | | if err != nil { |
| | | fmt.Println("读取配置文件出错--", err) |
| | | logger.Error("读取配置文件出错--", err) |
| | | } |
| | | c := conf{} |
| | | //把yaml形式的字符串解析成struct类型 |
| | | yaml.Unmarshal(data, &c) |
| | | weedfsUrl = c.PhotoUrl |
| | | videoPersonUrl = c.VideoPersons |
| | | personAction = c.PersonAction |
| | | } |
| | | //func InitInsertEs() { |
| | | // weedfsUrl = "http://"+WeedFs.Ip+":"+strconv.Itoa(WeedFs.UploadPort)+"/submit" |
| | | // videoPersonUrl = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType |
| | | // personAction = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType |
| | | //} |
| | | |
| | | // 人脸的数据结构 |
| | | type PerVideoPicture struct { |
| | |
| | | // //} |
| | | //} |
| | | func InsertToEs(msg ruleserver.ResultMsg) { |
| | | defer func() { |
| | | if err := recover(); err != nil { |
| | | logger.Error("es模块儿的异常捕获:",err) |
| | | } |
| | | }() |
| | | localConfig1, err := cache.GetServerInfo() |
| | | if err != nil { |
| | | panic("配置文件不合法") |
| | | } |
| | | weedfsUrl = "http://"+localConfig1.WebPicIp+":"+strconv.Itoa(int(localConfig1.WebPicPort))+"/submit" |
| | | videoPersonUrl = "http://"+localConfig1.AlarmIp+":"+strconv.Itoa(int(localConfig1.AlarmPort))+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType |
| | | personAction = "http://"+localConfig1.AlarmIp+":"+strconv.Itoa(int(localConfig1.AlarmPort))+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType |
| | | InsertFace(msg, "") |
| | | // 如果标签中含有持续时间首次报警的timeLabel的话则不需要过人体追踪,不然就没的插入了 |
| | | fk := ruleserver.TrackOrNot(msg.RuleResult) |
| | |
| | | faces = PutFace(faces,msg) |
| | | //logger.Info("整理后的数据:",faces) |
| | | if faces != nil { |
| | | var imgMaxUrl string = "" |
| | | var picTime string = "" |
| | | for _,face := range faces { |
| | | // 上传大图 |
| | | // 解压缩并上传图片 |
| | |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | bigPhotoUrl := make(map[string]interface{}) |
| | | bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | logger.Debug("========大图路径:", bigPhotoUrl) |
| | | if imgMaxUrl == "" { |
| | | bigPhotoUrl := make(map[string]interface{}) |
| | | bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | logger.Debug("========大图路径:", bigPhotoUrl) |
| | | imgMaxUrl = bigPhotoUrl["fileUrl"].(string) |
| | | picTime = i.Timestamp |
| | | } |
| | | // 人脸检测,没有相似的底库人员 |
| | | localConfig, err := cache.GetServerInfo() |
| | | if err != nil { |
| | |
| | | if linkId != "" { |
| | | linksId = linkId |
| | | } |
| | | logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10)) |
| | | logger.Info("人脸的分值:",face.Score) |
| | | //logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10)) |
| | | //logger.Info("人脸的分值:",face.Score) |
| | | pervideo := PerVideoPicture{ |
| | | esDataId, |
| | | msg.Cid, |
| | | camera.Addr, |
| | | i.Timestamp, |
| | | bigPhotoUrl["fileUrl"].(string), |
| | | picTime, |
| | | imgMaxUrl, |
| | | msg.Tasklab.Taskid, |
| | | msg.Tasklab.Taskname, |
| | | "人脸", |
| | |
| | | } else { |
| | | logger.Info("上传的图片信息:", resp1) |
| | | } |
| | | url = append(url, resp1["fileUrl"].(string)) |
| | | if resp1["fileUrl"] != nil { |
| | | url = append(url, resp1["fileUrl"].(string)) |
| | | } |
| | | } |
| | | } |
| | | } |