Example #1
0
        public async Task <Dictionary <string, string> > AnalyseImageUrlAsync(string url)
        {
            var image = await Image.FetchFromUriAsync(url);

            var response = await ImageClient.DetectSafeSearchAsync(image);

            return(GetTrigeredFlags(response));
        }
Example #2
0
        private async Task <bool> IsSfw(string url, bool isChanNsfw)
        {
            var image = await Google.Cloud.Vision.V1.Image.FetchFromUriAsync(url);

            SafeSearchAnnotation response = await imageClient.DetectSafeSearchAsync(image);

            if (isChanNsfw)
            {
                return((int)response.Medical < 3 && (int)response.Violence < 3);
            }
            return((int)response.Adult < 3 && (int)response.Medical < 3 && (int)response.Violence < 3);
        }
Example #3
0
        private async Task <bool> IsImageSafe(Image image)
        {
            try
            {
                var annotation = await _annotator.DetectSafeSearchAsync(image);

                return(annotation.Adult < Likelihood.Possible &&
                       annotation.Medical < Likelihood.Possible &&
                       annotation.Spoof < Likelihood.Possible &&
                       annotation.Violence < Likelihood.Possible);
            }
            catch (AnnotateImageException e)
            {
                _logger.LogError(e, e.Message);
                return(false);
            }
        }