panlei
2019-07-05 6cc33b9bcbf1db10bb1ca3683d6fe80af1abf6b8
人脸提取的上传
1个文件已修改
91 ■■■■ 已修改文件
insertdata/insertDataToEs.go 91 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
insertdata/insertDataToEs.go
@@ -47,21 +47,7 @@
    IsAckAlarm      int      `json:"isAckAlarm"`
    IsCollect       int      `json:"isCollect"`
    IsDelete        int      `json:"isDelete"`
    BaseInfo        []Base   `json:"baseInfo"`
}
type Base struct {
    TableId      string  `json:"tableId"`
    TableName    string  `json:"tableName"`
    CompareScore float64 `json:"compareScore"`
    PersonId     string  `json:"personId"`
    PersonName   string  `json:"personName"`
    PersonPicUrl string  `json:"personPicUrl"`
    PhoneNum     string  `json:"phoneNum"`
    Sex          string  `json:"sex"`
    IdCard       string  `json:"idCard"`
    MonitorLevel string  `json:"monitorLevel"`
    Content      string  `json:"content"`
    BaseInfo        []*protomsg.Baseinfo   `json:"baseInfo"`
}
//  yolo行为的数据结构
@@ -163,7 +149,7 @@
                    race,
                    face.ThftRes.Smile,
                    face.ThftRes.Beauty,
                    "不是每个人脸算法都有",
                    "",
                    []string{strings.Split(resp["fileUrl"].(string), "/")[1]},
                    "暂无集群",
                    localConfig.ServerId,
@@ -174,7 +160,7 @@
                    0,
                    0,
                    0,
                    []Base{},
                    []*protomsg.Baseinfo{},
                }
                requstbody, err := json.Marshal(pervideo)
@@ -186,7 +172,78 @@
                err = EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody)
                //logger.Info(err.Error())
            } else {
                // 人脸提取
                localConfig, err := cache.GetServerInfo()
                if err != nil {
                    logger.Info("查询本机信息失败!")
                }
                serverIp, err := GetLocalIP()
                // 解压缩并上传图片
                bdata, err := util.UnCompress(msg.Data)
                if err != nil {
                    panic("解压缩图片时出现错误")
                }
                // 查询cameraName
                camera, err := cache.GetCameraById(msg.Cid)
                if err != nil {
                    logger.Info("查询摄像机信息失败")
                }
                i := protomsg.Image{}
                err = proto.Unmarshal(bdata, &i)
                logger.Info("-------------------------------------------看下宽和高", i.Width, i.Height)
                bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height))
                resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String())
                if err != nil {
                    logger.Info("上传小图出错")
                }
                sex := ""
                if face.ThftRes.Gender == 1 {
                    sex = "男"
                } else {
                    sex = "女"
                }
                race := getRaceString(face.ThftRes.Race)
                ageDescription := getDescription(face.ThftRes.Age)
                pervideo := PerVideoPicture{
                    uuid.NewV4().String(),
                    msg.Cid,
                    camera.Addr,
                    time.Now().Format("2006-01-02 15:04:05"),
                    strings.Split(bigPhotoUrl["fileUrl"].(string), "/")[1],
                    msg.Tasklab.Taskid,
                    msg.Tasklab.Taskname,
                    "人脸",
                    "",
                    time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
                    sex,
                    face.ThftRes.Age,
                    ageDescription,
                    race,
                    face.ThftRes.Smile,
                    face.ThftRes.Beauty,
                    "",
                    []string{strings.Split(resp["fileUrl"].(string), "/")[1]},
                    "暂无集群",
                    localConfig.ServerId,
                    localConfig.ServerName,
                    serverIp,
                    "",
                    1,
                    0,
                    0,
                    0,
                    face.Liker,
                }
                requstbody, err := json.Marshal(pervideo)
                if err != nil {
                    logger.Info("json parse error ", err)
                    return
                }
                err = EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody)
                logger.Info("跟底库的相似数据---------:", face.Liker)
                fmt.Println("------------------------------------------哈哈哈哈,底库有人")
            }