| | |
| | | return |
| | | } |
| | | var faceB []byte |
| | | var uploadImage string |
| | | var smImages []string |
| | | //if searchBody.CaptureId != "" {//做查找此人,搜所有抓拍和底库 |
| | | // searchBase64Fea, err := esApi.GetVideoPersonFaceFeatureById(searchBody.CaptureId, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | // if err !=nil { |
| | | // util.ResponseFormat(c, code.ComError, "抓拍数据不存在,请检查") |
| | | // return |
| | | // } |
| | | // if searchBase64Fea !=""{ |
| | | // decodeF, err := base64.StdEncoding.DecodeString(searchBase64Fea) |
| | | // if err !=nil { |
| | | // util.ResponseFormat(c, code.ComError, "本条抓怕特征不是base64,请检查") |
| | | // return |
| | | // } |
| | | // faceB = decodeF |
| | | // } |
| | | //} else {//做以图搜图 |
| | | // |
| | | //} |
| | | |
| | | if searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | if face,ok := faceExtractedMap[searchBody.PicUrl];!ok{ |
| | | httpPicUrl := "" |
| | | idx := strings.LastIndex(searchBody.PicUrl, ":") |
| | | if idx>-1 { |
| | | httpPicUrl = "http://"+localConf.WebPicIp+searchBody.PicUrl[idx:] |
| | | if searchBody.CompTargetId != "" {//做查找此人,按抓拍的人脸或者底库的人脸以图搜图 |
| | | if searchBody.CompTargetType == 0 {//本张人脸是底库人脸 |
| | | var dbpApi dbapi.DbPersonApi |
| | | dbPersons, e := dbpApi.Dbpersoninfosbyid([]string{searchBody.CompTargetId}) |
| | | if e ==nil && dbPersons !=nil && len(dbPersons) ==1 { |
| | | searchBase64Fea := dbPersons[0].FaceFeature |
| | | if searchBase64Fea != "" { |
| | | decodeF, err := base64.StdEncoding.DecodeString(dbPersons[0].FaceFeature) |
| | | if err !=nil { |
| | | util.ResponseFormat(c, code.ComError, "本条底库人员特征不是base64,请检查") |
| | | return |
| | | } |
| | | faceB = decodeF |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError, "本条底库人员特征为空,请检查") |
| | | return |
| | | } |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError, "底库人员查询失败,请检查") |
| | | return |
| | | } |
| | | } else { |
| | | util.ResponseFormat(c, code.RequestParamError, "图片路径有误,请重新上传图片") |
| | | searchBase64Fea, err := esApi.GetVideoPersonFaceFeatureById(searchBody.CompTargetId, config.EsInfo.EsIndex.VideoPersons.IndexName, localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort))) |
| | | if err !=nil { |
| | | util.ResponseFormat(c, code.ComError, "抓拍数据不存在,请检查") |
| | | return |
| | | } |
| | | if searchBase64Fea !=""{ |
| | | decodeF, err := base64.StdEncoding.DecodeString(searchBase64Fea) |
| | | if err !=nil { |
| | | util.ResponseFormat(c, code.ComError, "本条抓怕特征不是base64,请检查") |
| | | return |
| | | } |
| | | faceB = decodeF |
| | | } |
| | | } |
| | | |
| | | } else {//做以图搜图 |
| | | if searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "以图搜图PicUrl不能为空") |
| | | return |
| | | } |
| | | logger.Debug("httpPicUrl:",httpPicUrl) |
| | | rb,err := util.ReadImgData(httpPicUrl) |
| | | if err !=nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "读取图片失败,请重新上传图片") |
| | | return |
| | | } |
| | | feaB, oriImg, smImgs, e := GetFeaFromOneFaceImg(rb) |
| | | if e !=nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "未提取到特征,请重新上传图片") |
| | | if face,ok := faceExtractedMap[searchBody.PicUrl];!ok{ |
| | | util.ResponseFormat(c, code.RequestParamError, "人脸特征未检测,请重新上传图片") |
| | | return |
| | | } else { |
| | | uploadImage = oriImg |
| | | smImages = smImgs |
| | | faceB = feaB |
| | | faceB = face.FaceBytes |
| | | } |
| | | } else { |
| | | faceB = face.FaceBytes |
| | | } |
| | | |
| | | if faceB == nil { |
| | |
| | | CompareData: &totalData, |
| | | }) |
| | | |
| | | m := make(map[string]interface{},5) |
| | | m["uploadImage"] = uploadImage |
| | | m["smImage"] = smImages |
| | | m := make(map[string]interface{},3) |
| | | if totalData != nil && totalData.Len() > 0{ |
| | | sort.Sort(totalData) |
| | | total := totalData.Len() |