ethan.roday
ethan.roday

Reputation: 2645

Get hex codes for colors using Azure Cognitive Services Vision API

Is there a way to get hex codes for the dominant background and foreground colors from the Azure Computer Vision API? The color information in the default response looks like this:

"color": {
  "dominantColorForeground": "Black",
  "dominantColorBackground": "Black",
  "dominantColors": [
    "Black",
    "Grey"
  ],
  "accentColor": "7B5E50",
  "isBWImg": false
}

There's a hex code for the accent color, but does anyone know if there's a way to get hex codes for the other colors (specifically the dominant foreground and background colors)? I couldn't find anything in the documentation but figured I might have missed something.

Upvotes: 0

Views: 193

Answers (1)

Nicolas R
Nicolas R

Reputation: 14619

There is no equivalent provided directly by the API.

You can do it simply by code, for example in C# as mentioned in this topic: How to convert color name to the corresponding hexadecimal representation?

int ColorValue = Color.FromName("blue").ToArgb();
string ColorHex = string.Format("{0:x6}", ColorValue);

Upvotes: 1

Related Questions