liuxiaolong
2019-07-24 8e732dbff0367329597fc95765bccf206b20e667
controllers/fileController.go
@@ -120,11 +120,12 @@
      return
   }
   var weedfsUri = "http://"+config.WeedFs.Ip+":"+strconv.Itoa(config.WeedFs.UploadPort)+"/submit"
   resultMap :=make(map[string]interface{},0)
   //将上传的图片交人脸检测和人脸提取,获得特征
   fileBytes, _ := ioutil.ReadAll(file)
   faceArr, err, pI := service.GetFaceFeaFromSdk(fileBytes, time.Second*60)
   if err ==nil && len(faceArr) >0 {
      //1.提取每一张人脸小图
      urlArr := make([]string,0)
      for _,r := range faceArr {
         rcFace := r.Pos.RcFace
@@ -138,8 +139,11 @@
            urlArr = append(urlArr, weedFilePath)
         }
      }
      util.ResponseFormat(c,code.Success,urlArr)
      //2.大图画框
      originFilePath, _ := WeedFSClient.UploadFile(weedfsUri, "FaceUrl", fileBytes)
      resultMap["uploadImage"] = originFilePath
      resultMap["smImage"] = urlArr
      util.ResponseFormat(c,code.Success, resultMap)
   } else {
      util.ResponseFormat(c,code.ComError,"未提取到人脸")
   }
@@ -150,12 +154,17 @@
// @Produce json
// @Tags 以图搜图
// @Param url formData string true "url"
// @Param tableId formData string true "底库id"
// @Param compThreshold formData string true "比对阈值"
// @Success 200 {string} json "{"code":200, msg:"", data:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", data:"", success:false}"
// @Router /data/api-v/dbperson/searchByPhoto [POST]
func (controller FileController) SearchByPhoto(c *gin.Context) {
   photoUrl := c.Request.FormValue("url")
   if photoUrl == "" {
   tableId := c.Request.FormValue("tableId")//底库id
   compThresholdStr := c.Request.FormValue("compThreshold")//比对阈值
   compThreshold, err := strconv.Atoi(compThresholdStr)
   if photoUrl == "" || err != nil {
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
   }
@@ -164,8 +173,9 @@
      return
   } else {
      arg := protomsg.CompareArgs{
         TableIds:[]string{ tableId },
         FaceFeature:face.FaceBytes,
         CompareThreshold:0.2,
         CompareThreshold:float32(compThreshold),
      }
      b, err := proto.Marshal(&arg)
      if err !=nil{