googleapis/nodejs-vision

Discrepancy in information pulled in Cloud Vision website vs API - DominantColorAnnotation

potcheeks opened this issue · 1 comments

hi there, the results I get from using the API vs what I get from the website are very different. I understand that the highest score reflects most accurately the dominant colour. But I've uploaded the picture to both the website and my backend server (which calls the API) and the results from the JSON file from the google website and my data are different.

for example this is what I get from my log (10 results)

{ color: { red: 225, green: 226, blue: 223, alpha: null }, score: 0.28191062808036804, pixelFraction: 0.41662895679473877 }, { color: { red: 24, green: 27, blue: 35, alpha: null }, score: 0.11526796966791153, pixelFraction: 0.09317941963672638 }, { color: { red: 210, green: 210, blue: 206, alpha: null }, score: 0.070244699716568, pixelFraction: 0.09265127778053284 }, { color: { red: 41, green: 49, blue: 63, alpha: null }, score: 0.1388927698135376, pixelFraction: 0.08767164498567581 }, { color: { red: 44, green: 47, blue: 57, alpha: null }, score: 0.09161456674337387, pixelFraction: 0.07393994182348251 }, { color: { red: 24, green: 30, blue: 44, alpha: null }, score: 0.10027392953634262, pixelFraction: 0.061641767621040344 }, { color: { red: 72, green: 83, blue: 99, alpha: null }, score: 0.04788002744317055, pixelFraction: 0.03123585321009159 }, { color: { red: 76, green: 80, blue: 88, alpha: null }, score: 0.02934001013636589, pixelFraction: 0.026859816163778305 }, { color: { red: 105, green: 118, blue: 134, alpha: null }, score: 0.020987385883927345, pixelFraction: 0.013882601633667946 }, { color: { red: 73, green: 42, blue: 26, alpha: null }, score: 0.01754932850599289, pixelFraction: 0.00920476857572794 } ]

vs this is what I get from the website

"dominantColors": { "colors": [ { "color": { "blue": 63, "green": 49, "red": 41 }, "hex": "29313F", "percent": 31.317973386555092, "percentRounded": 31, "pixelFraction": 0.087671645, "rgb": "41, 49,\n 63", "score": 0.29549706 }, { "color": { "blue": 86, "green": 107, "red": 150 }, "hex": "966B56", "percent": 2.4598561685261897, "percentRounded": 2, "pixelFraction": 0.015919723, "rgb": "150, 107,\n 86", "score": 0.023209684 },

I will not paste the whole thing but the first result from the json is the most accurate colour. If you compare their scores its different. Any idea why? I've been playing around with this for nearly a week.)

Why is there a discrepancy?

Would appreciate all the guidance.
This is my code to get the logged results.
const colors = results[0]?.imagePropertiesAnnotation.dominantColors.colors; colors?.forEach(color => console.log("all the colours",color)); const dominantColour = colors[0]?.color;

The demo on the website is intended to showcase the functionality, but is not a "source of truth" for testing.

If we are able to find out any more specifics about parameters, API version, etc. used in the demo, we can update this ticket.

We'll go ahead and close this issue for now, as there isn't a bug in the Node JS library, which this repo supports.