| | |
| | | |
| | | var captureTable = "capturetable" // 抓拍库 |
| | | type SearchCondition struct { |
| | | Url string `json:"url"` |
| | | TableIds []string `json:"tableIds"` |
| | | CompThreshold string `json:"compThreshold"` |
| | | PicUrl string `json:"picUrl"` |
| | | Databases []string `json:"databases"` |
| | | Threshold string `json:"threshold"` |
| | | } |
| | | // @Summary 以图搜图 |
| | | // @Description 以图搜图 |
| | |
| | | func (controller FileController) SearchByPhoto(c *gin.Context) { |
| | | var condition SearchCondition |
| | | err := c.BindJSON(&condition) |
| | | if err !=nil || condition.Url == "" { |
| | | if err !=nil || condition.PicUrl == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | compThreshold, err := strconv.ParseFloat(condition.CompThreshold,32) |
| | | if condition.Url == "" || err != nil { |
| | | compThreshold, err := strconv.ParseFloat(condition.Threshold,32) |
| | | if condition.PicUrl == "" || err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | if face,ok := faceExtractedMap[condition.Url];!ok{ |
| | | if face,ok := faceExtractedMap[condition.PicUrl];!ok{ |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } else { |
| | |
| | | FaceFeature:face.FaceBytes, |
| | | CompareThreshold:float32(compThreshold), |
| | | } |
| | | if condition.TableIds !=nil { |
| | | arg.TableIds = append(arg.TableIds, condition.TableIds...) |
| | | if condition.Databases !=nil { |
| | | arg.TableIds = append(arg.TableIds, condition.Databases...) |
| | | } |
| | | b, err := proto.Marshal(&arg) |
| | | if err !=nil{ |