| | |
| | | "log" |
| | | "mime/multipart" |
| | | "net/http" |
| | | "strings" |
| | | "webserver/extend/code" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | |
| | | |
| | | //var picUrlField = "fid" |
| | | /**上传方法**/ |
| | | //var weedfsUri = "http://192.168.1.182:6333/submit" |
| | | var weedfsUri = "http://192.168.1.182:6333/submit" |
| | | |
| | | var weedfsUri = "http://192.168.1.182:9500/submit" |
| | | //var weedfsUri = "http://192.168.1.182:9500/submit" |
| | | |
| | | // @Summary 依据图片添加底库人员 |
| | | // @Description 依据图片添加底库返回数据人员 |
| | |
| | | field = fileInfo[picUrlField].(string) // 文件路径 |
| | | } |
| | | } |
| | | if tableId != "" && field != "" { |
| | | if field != "" { |
| | | // 返回特征值 fileInfo["point"] = v.RcFace fileInfo["feature"] = feat |
| | | |
| | | /*features := gorun.GetSimpleFaceDetect(picIp+field) // 特征值 // linux |
| | |
| | | return field,nil,errors.New("NotFeatureFindError") |
| | | |
| | | } */ // linux |
| | | if strings.Contains(field,"/"){ |
| | | idx := strings.Index(field, "/") |
| | | field = field[:idx+1] |
| | | } |
| | | |
| | | //将上传的图片交人脸检测和人脸提取,获得特征 |
| | | var faceBase64="" |
| | | faceExtArr, err := getFaceFeaFromSdk(file) |
| | | if faceExtArr ==nil { |
| | | return "",nil,errors.New("NotFeatureFindError") |
| | | } |
| | | if err ==nil && len(faceExtArr) >0 { |
| | | for _,r := range faceExtArr { |
| | | faceBase64 = base64.StdEncoding.EncodeToString(r.Feats)//获取提取到的第一张人脸特征 |
| | |
| | | |
| | | |
| | | dbperson := new(models.Dbtablepersons) |
| | | dbperson.FaceFeature = picIp + field // 图片路经 |
| | | dbperson.PersonPicUrl = field // 图片路经 |
| | | dbperson.TableId = tableId // |
| | | dbperson.PersonName = filename // 图片名 |
| | | // 演示base64编码 |
| | |
| | | } |
| | | } |
| | | |
| | | type EsPersonSave struct { |
| | | FaceFeature string `json:"faceFeature"` |
| | | TableId string `json:"tableId"` |
| | | Id string `json:"id"` |
| | | PersonPicUrl string `json:"personPicUrl"` |
| | | IdCard string `json:"idCard"` |
| | | } |
| | | |
| | | // @Summary 上传图片 并切图 |
| | | // @Description 上传图片 并切图 |
| | | // @Accept mpfd |
| | |
| | | // @Tags dbperson 底库人员 |
| | | // @Param file formData file true "底库人员图片" |
| | | // @Param tableId formData string false "底库id,有id 则加入底库,无则只上传图片" |
| | | // @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}" |
| | | // @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}" |
| | | // @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true, data:""}" |
| | | // @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false, data:""}" |
| | | // @Router /data/api-v/es/ImageUploadReturnPics [POST] |
| | | func (fc FileController) ImageUploadReturnPics(c *gin.Context) { |
| | | //得到上传的文件 |
| | |
| | | } |
| | | //文件的名称 |
| | | filename := header.Filename |
| | | fmt.Println(file, err, filename) |
| | | defer file.Close() |
| | | field := "" |
| | | |
| | | // weedfs 上传 |
| | | uploadData := make([]byte, header.Size) |
| | | i, err2 := file.ReadAt(uploadData, 0) |
| | |
| | | // fileInfo["point"] = v.RcFace // 返回特征值 |
| | | // fileInfo["feature"] = feat |
| | | //features := gorun.GetSimpleFaceDetect(picIp + "/" + field) // 特征值 只在linux 下 |
| | | //feat := []byte("hello world") // windows 测试放开 |
| | | |
| | | result := make(map[string]interface{}, 0) |
| | | result["uploadImage"] = picIp + field |
| | | smUrl := make([]string, 0) |