| | |
| | | } |
| | | var faceExtractedMap = make(map[string]FaceExtract,0) |
| | | |
| | | // @Description 人脸提取 |
| | | // @Summary 人脸提取 |
| | | // @Description 人脸提取 |
| | | // @Produce json |
| | | // @Tags 以图搜图 |
| | | // @Param file formData file 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/faceExtract [POST] |
| | | func (controller FileController) FaceExtract(c *gin.Context) { |
| | | file, _, err := c.Request.FormFile("file") //image这个是uplaodify参数定义中的 'fileObjName':'image' |
| | |
| | | urlArr = append(urlArr, weedFilePath) |
| | | } |
| | | } |
| | | if len(urlArr) == 0{ |
| | | util.ResponseFormat(c,code.ComError,"未提取到人脸") |
| | | } else { |
| | | util.ResponseFormat(c,code.Success,urlArr) |
| | | } |
| | | |
| | | util.ResponseFormat(c,code.Success,urlArr) |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"未提取到人脸") |
| | | } |
| | | } |
| | | |
| | | // @Description 以图搜图 |
| | | // @Summary 以图搜图 |
| | | // @Description 以图搜图 |
| | | // @Produce json |
| | | // @Tags 以图搜图 |
| | | // @Param url formData string true "url" |
| | | // @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") |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } else { |
| | | reqUrl := "tcp://192.168.1.66:40010" |
| | | reqClient := deliver.NewClient(deliver.ReqRep, reqUrl) |
| | | arg := protomsg.CompareArgs{ |
| | | FaceFeature:face.FaceBytes, |
| | | CompareThreshold:0.2, |
| | |
| | | util.ResponseFormat(c, code.ComError, "请求marshal失败") |
| | | return |
| | | } |
| | | err = reqClient.Send(b) |
| | | if err !=nil{ |
| | | util.ResponseFormat(c, code.ComError, "比对服务请求失败") |
| | | return |
| | | compServerList := config.CompServerInfo.Url |
| | | fmt.Println("compServerList:", compServerList) |
| | | resultList :=make([]protomsg.Dbperson,0) |
| | | for _,str :=range compServerList{ |
| | | reqUrl := "tcp://"+str |
| | | reqClient := deliver.NewClient(deliver.ReqRep, reqUrl) |
| | | err = reqClient.Send(b) |
| | | if err !=nil{ |
| | | continue |
| | | } |
| | | resultB, err := reqClient.Recv() |
| | | if err !=nil{ |
| | | continue |
| | | } |
| | | m :=make(map[string]float32,0) |
| | | err = json.Unmarshal(resultB, &m) |
| | | if err !=nil{ |
| | | continue |
| | | } |
| | | personIds := make([]string,len(m)) |
| | | for k,_ :=range m{ |
| | | personIds = append(personIds,k) |
| | | } |
| | | esServerIp := config.EsInfo.Masterip |
| | | esServerPort := config.EsInfo.Httpport |
| | | index := config.EsInfo.EsIndex.Dbtablepersons.IndexName |
| | | dbpeople, e := esApi.Dbpersoninfosbyid(personIds, index, esServerIp, esServerPort) |
| | | if e ==nil{ |
| | | resultList = append(resultList,dbpeople...) |
| | | } |
| | | } |
| | | resultB, err := reqClient.Recv() |
| | | if err !=nil{ |
| | | util.ResponseFormat(c, code.ComError, "比对服务响应失败") |
| | | return |
| | | } |
| | | m :=make(map[string]float32,0) |
| | | err = json.Unmarshal(resultB, &m) |
| | | if err !=nil{ |
| | | util.ResponseFormat(c, code.ComError, "result Unmarshal err") |
| | | return |
| | | } |
| | | personIds := make([]string,len(m)) |
| | | for k,_ :=range m{ |
| | | personIds = append(personIds,k) |
| | | } |
| | | dbpeople, e := esApi.Dbpersoninfosbyid(personIds, "dbtablepersons", "192.168.1.182", "9200") |
| | | if e !=nil{ |
| | | util.ResponseFormat(c, code.ComError, "result es query err") |
| | | } else { |
| | | util.ResponseFormat(c,code.Success,dbpeople) |
| | | } |
| | | util.ResponseFormat(c,code.Success,resultList) |
| | | } |
| | | } |
| | | |