How to use the @google-cloud/vision.types function in @google-cloud/vision

To help you get started, we’ve selected a few @google-cloud/vision examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / friendlypix-web / functions / blurOffensiveImages.js View on Github external
return vision.safeSearchDetection(image).then((batchAnnotateImagesResponse) => {
    console.log('SafeSearch results on image', batchAnnotateImagesResponse);
    const safeSearchResult = batchAnnotateImagesResponse[0].safeSearchAnnotation;
    const Likelihood = Vision.types.Likelihood;

    if (Likelihood[safeSearchResult.adult] >= Likelihood.LIKELY ||
        Likelihood[safeSearchResult.violence] >= Likelihood.LIKELY) {
      return blurImage(object.name, object.bucket, object.metadata).then(() => {
        const filePathSplit = object.name.split(path.sep);
        const uid = filePathSplit[0];
        const size = filePathSplit[1]; // 'thumb' or 'full'
        const postId = filePathSplit[2];

        return refreshImages(uid, postId, size);
      });
    }
    console.log('The image', object.name, 'has been detected as OK.');
  });
});
github ccckmit / ccckmit / course / webProgramming / example / database / firebase / friendlychat-web / cloud-functions / functions / index.js View on Github external
return vision.safeSearchDetection(image).then(batchAnnotateImagesResponse => {
    const safeSearchResult = batchAnnotateImagesResponse[0].safeSearchAnnotation;
    const Likelihood = Vision.types.Likelihood;
    if (Likelihood[safeSearchResult.adult] >= Likelihood.LIKELY ||
        Likelihood[safeSearchResult.violence] >= Likelihood.LIKELY) {
      console.log('The image', object.name, 'has been detected as inappropriate.');
      return blurImage(object.name, object.bucket);
    } else {
      console.log('The image', object.name,'has been detected as OK.');
    }
  });
});