| | |
| | | "mime/multipart" |
| | | "net/http" |
| | | "path" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | |
| | | Sex string `json:"sex"` |
| | | TableId string `json:"tableId"` |
| | | TableName string `json:"tableName"` |
| | | Enable int32 `json:"enable"` |
| | | } |
| | | |
| | | type CompareSortResult []CompareResult |
| | | |
| | | func (s CompareSortResult) Len() int{ |
| | | return len(s) |
| | | } |
| | | func (s CompareSortResult) Swap(i,j int){ |
| | | s[i],s[j] = s[j],s[i] |
| | | } |
| | | func (s CompareSortResult) Less(i,j int) bool{ |
| | | return s[i].CompareScore > s[j].CompareScore |
| | | } |
| | | |
| | | //填充向前端返回的数据 |
| | | func FillDataToCompareResult(compResult *protomsg.SdkCompareResult) []CompareResult { |
| | | resultList :=make([]CompareResult,0) |
| | | func FillDataToCompareResult(compResult *protomsg.SdkCompareResult) CompareSortResult { |
| | | //resultList :=make([]CompareResult,0) |
| | | var resultList = CompareSortResult{} |
| | | |
| | | dbPersonM := make(map[string]*protomsg.SdkCompareEach, 0) |
| | | captureM := make(map[string]*protomsg.SdkCompareEach, 0) |
| | |
| | | PhoneNum: p.PhoneNum, |
| | | Sex: p.Sex, |
| | | TableId: p.TableId, |
| | | Enable: p.Enable, |
| | | } |
| | | dbTableInfos, _ := esApi.Dbtablefosbyid([]string{p.TableId}, config.EsInfo.EsIndex.DbTables.IndexName, esServerIp, esServerPort) |
| | | if dbTableInfos !=nil{ |
| | |
| | | PhoneNum: p.PhoneNum, |
| | | Sex: p.Sex, |
| | | TableId: p.TableId, |
| | | BwType: strconv.Itoa(int(p.BwType)), |
| | | TableName: p.TableName, |
| | | }) |
| | | } |
| | | vpE := CompareResult{ |
| | |
| | | resultList = append(resultList,vpE) |
| | | } |
| | | } |
| | | sort.Sort(resultList) |
| | | return resultList |
| | | } |
| | | |
| | |
| | | compareService := service.NewFaceCompareService(arg) |
| | | compareOnce := compareService.Compare() |
| | | totalData := compareOnce.CompareData |
| | | |
| | | logger.Debug("comp 比对结束,用时:",time.Since(timeStart)) |
| | | m := make(map[string]interface{},3) |
| | | if totalData!=nil && len(*totalData)>0{ |
| | | if totalData != nil && totalData.Len() > 0{ |
| | | //按分值排序 |
| | | service.SortByScore(totalData) |
| | | total := len(*totalData) |
| | | 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) |
| | | } |
| | | //logger.Debug("comp 排序后分值数组:",scoreAf) |
| | | total := totalData.Len() |
| | | |
| | | m["compareNum"] = compareOnce.CompareNum |
| | | m["total"] = total |