| | |
| | | |
| | | dbPersonM := make(map[string]*protomsg.SdkCompareEach, 0) |
| | | captureM := make(map[string]*protomsg.SdkCompareEach, 0) |
| | | personIds :=make([]string,0) |
| | | personIds := make([]string,0) |
| | | captureIds := make([]string,0) |
| | | for _,v :=range compResult.CompareResult{ |
| | | if v.Tableid == service.CaptureTable { |
| | |
| | | dbpersons, _ = esApi.Dbpersoninfosbyid(personIds, index, esServerIp, esServerPort) |
| | | } |
| | | |
| | | logger.Debug("comp dbpersons.len:", len(dbpersons)) |
| | | if dbpersons !=nil { |
| | | if len(dbpersons) >0 { |
| | | for _,p :=range dbpersons { |
| | | var dbP = DbPersonVo { |
| | | PersonId: p.Id, |
| | |
| | | resultList = append(resultList,vpE) |
| | | } |
| | | } |
| | | var scorePre []float32 |
| | | for _,f1 :=range resultList { |
| | | scorePre = append(scorePre, f1.CompareScore) |
| | | } |
| | | logger.Debug("comp 排序前分值数组:",scorePre) |
| | | sort.Sort(resultList) |
| | | var scoreAf []float32 |
| | | for _,f2 :=range resultList { |
| | | scoreAf = append(scoreAf, f2.CompareScore) |
| | | } |
| | | logger.Debug("comp 排序后分值数组:",scoreAf) |
| | | return resultList |
| | | } |
| | | |
| | |
| | | func (controller FileController) SearchByPhoto(c *gin.Context) { |
| | | var searchBody models.EsSearch |
| | | err := c.BindJSON(&searchBody) |
| | | if err !=nil || searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 { |
| | | if err !=nil{ |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | var faceB []byte |
| | | if searchBody.CaptureId != "" {//做查找此人 |
| | | searchPeople, err := esApi.Dbpersoninfosbyid([]string{searchBody.CaptureId}, config.EsInfo.EsIndex.VideoPersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | if searchBody.CaptureId != "" {//做查找此人,搜所有抓拍和底库 |
| | | searchBase64Fea, err := esApi.GetVideoPersonFaceFeatureById(searchBody.CaptureId, config.EsInfo.EsIndex.VideoPersons.IndexName, config.EsInfo.Masterip, config.EsInfo.Httpport) |
| | | if err !=nil { |
| | | util.ResponseFormat(c, code.ComError, "抓拍数据不存在,请检查") |
| | | return |
| | | } |
| | | if searchPeople !=nil && len(searchPeople) == 1{ |
| | | decodeF, err := base64.StdEncoding.DecodeString(searchPeople[0].FaceFeature) |
| | | 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{ |
| | | util.ResponseFormat(c, code.RequestParamError, "请重新上传图片") |
| | | return |
| | | } else { |
| | | faceB = face.FaceBytes |
| | | } |
| | | } |
| | | //if searchBody.CompareNum !="" { |
| | | // //二次搜索,不需要再比对了 |
| | | // co := service.GetCompResultByNum(searchBody.CompareNum) |
| | | // if co != nil { |
| | | // //二次搜索和排序 |
| | | // twiceM := GetCompareDataTwice(co,&searchBody) |
| | | // util.ResponseFormat(c,code.Success,twiceM) |
| | | // } else { |
| | | // m :=make(map[string]interface{},0) |
| | | // m["compareNum"] = searchBody.CompareNum |
| | | // m["total"] = 0 |
| | | // m["totalList"] = []CompareResult{} |
| | | // util.ResponseFormat(c,code.CompareResultGone,m) |
| | | // } |
| | | //} |
| | | |
| | | var sysSetApi dbapi.SysSetApi |
| | | analyServerId := "" |
| | | flag, sysconf := sysSetApi.GetServerInfo() |
| | |
| | | util.ResponseFormat(c, code.ComError, "analyServerId为空,配置有误") |
| | | return |
| | | } |
| | | if searchBody.CaptureId == ""{ |
| | | if face,ok := faceExtractedMap[searchBody.PicUrl];!ok{ |
| | | util.ResponseFormat(c, code.RequestParamError, "请重新上传图片") |
| | | return |
| | | } else { |
| | | faceB = face.FaceBytes |
| | | } |
| | | } |
| | | |
| | | if faceB == nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "请重新上传图片") |
| | | return |
| | |
| | | } |
| | | } |
| | | arg.TableIds = searchBody.DataBases |
| | | } else { |
| | | arg.TableIds = []string{} |
| | | } |
| | | arg.Source = true // 标识来源是web |
| | | arg.AlarmLevel = searchBody.AlarmLevel |
| | |
| | | m := make(map[string]interface{},3) |
| | | if totalData != nil && totalData.Len() > 0{ |
| | | //按分值排序 |
| | | var scorePre []float32 |
| | | for _,f1 :=range *totalData { |
| | | scorePre = append(scorePre, f1.CompareScore) |
| | | } |
| | | //var scorePre []float32 |
| | | //for _,f1 :=range *totalData { |
| | | // scorePre = append(scorePre, f1.CompareScore) |
| | | //} |
| | | //logger.Debug("comp 排序前分值数组:",scorePre) |
| | | sort.Sort(totalData) |
| | | var scoreAf []float32 |
| | | for _,f2 :=range *totalData { |
| | | scoreAf = append(scoreAf, f2.CompareScore) |
| | | } |
| | | //var scoreAf []float32 |
| | | //for _,f2 :=range *totalData { |
| | | // scoreAf = append(scoreAf, f2.CompareScore) |
| | | //} |
| | | //logger.Debug("comp 排序后分值数组:",scoreAf) |
| | | total := totalData.Len() |
| | | |
| | |
| | | addResult["successList"] = successList |
| | | addResult["failList"] = failList |
| | | addResult["fields"] = extNames |
| | | //addResult["detail"] = details |
| | | //fields := fdfsclient.UploadFileByBuffer100(bytess, extNames) // fastdfs 上传 |
| | | |
| | | if len(successList)>0 { |
| | | util.ResponseFormat(c, code.DbPersonUploadSuccess, addResult) |
| | | } else { |
| | | util.ResponseFormat(c, code.ServiceInsideError, err.Error()) |
| | | util.ResponseFormat(c, code.DbPersonUploadFail, addResult) |
| | | } |
| | | } |
| | | |