Here is a dump of a response from a Cloud Vision safeSearchDetection call you get by doing vision.safeSearchDetection(image).then(response => ...:
[
{
"faceAnnotations": [],
"landmarkAnnotations": [],
"logoAnnotations": [],
"labelAnnotations": [],
"textAnnotations": [],
"fullTextAnnotation": null,
"safeSearchAnnotation": {
"adult": "UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "LIKELY"
},
"imagePropertiesAnnotation": null,
"cropHintsAnnotation": null,
"webDetection": null,
"error": null
}
]
The values of the safeSearchAnnotation results should actually be numbers rather than Strings such as "UNLIKELY" as the docs explains: https://googlecloudplatform.github.io/google-cloud-node/#/docs/vision/0.12.0/vision/v1/data_types?method=SafeSearchAnnotation
and https://github.com/GoogleCloudPlatform/google-cloud-node/blob/vision-0.12.0/packages/vision/src/v1/doc/doc_image_annotator.js#L875
On a side note it would greatly help having the Likelyhood Enum available in the SDK (rather than just the docs) so we could do something like safeSearchAnnotation.adult >= vision.Likelyhood.POSSIBLE rather than safeSearchAnnotation.adult >= 3
@lukesneeringer wdyt?
Sorry for the delay @nicolasgarnier. After further investigation, it looks like the raw type is available already:
var Vision = require('@google-cloud/vision')
var visionClient = new Vision({...})
visionClient.annotateImage({...})
.then(responses => {
var response = responses[0]
console.log(Vision.types.Likelihood[response.safeSearchAnnotation.adult]) // 1
})
Regarding the docs being incorrect, this is unfortunate, but will be corrected soon as part of a module relocation effort. We are taking all of the modules out from this repo and putting them into their own. At the same time, the docs will move from GitHub to cloud.google.com in a completely new format.
Thanks @stephenplusplus , That's exactly the snippet I was looking for :)
Good luck with the docs!
Thank you!