in functions/image-analysis/go/response.go [54:67]
func (o *visionResponse) getDominantColor() (hex string) {
var bestScore float32
var bestColor *pb.ColorInfo
for _, color := range o.ImagePropertiesAnnotation.DominantColors.Colors {
if color.Score > bestScore {
bestScore = color.Score
bestColor = color
}
}
if bestColor == nil {
return "#ffffff"
}
return fmt.Sprintf("#%02x%02x%02x", int(bestColor.Color.Red), int(bestColor.Color.Green), int(bestColor.Color.Blue))
}