示例#1
0
        public async Task <string> UploadFileAsync(string imageFile, string fileNameForStorage, string extension)
        {
            var memoryFile = new MemoryStream(ImageConverter.Base64ToByte(imageFile.Replace($"data:image/{extension};base64,", "")));

            using (MemoryStream memoryStream = new MemoryStream())
            {
                var image = Image.FromStream(memoryFile);
                image.Save(memoryStream, image.RawFormat);
                var dataObject = await storageClient.UploadObjectAsync(bucketName, fileNameForStorage, null, memoryStream);

                return(dataObject.MediaLink);
            }
        }
示例#2
0
        /// <summary>
        /// Get all landmarks for this picture
        /// </summary>
        /// <param name="imageFile">Picture base 64</param>
        /// <param name="extension">Extension picture</param>
        /// <returns>All landmarks with over 70% of prediction</returns>
        public async Task <List <StepValidation> > GetWhat(string imageFile, string extension, int idStep)
        {
            IReadOnlyList <EntityAnnotation> landsmarks = await clientGoogle.DetectLandmarksAsync(Image.FromBytes(ImageConverter.Base64ToByte(imageFile.Replace($"data:image/{extension};base64,", ""))));

            return(landsmarks.Where(l => l.Score * 100 >= 65).Select(l => new StepValidation {
                Id = 0, IdStep = idStep, Description = l.Description, Score = l.Score
            }).ToList());
        }
示例#3
0
        public void GetWeb(string imageFile, string extension)
        {
            WebDetection webDetection = clientGoogle.DetectWebInformation(Image.FromBytes(ImageConverter.Base64ToByte(imageFile.Replace($"data:image/{extension};base64,", ""))));

            foreach (WebDetection.Types.WebEntity entity in webDetection.WebEntities)
            {
                Console.WriteLine($"Web entity: {entity.EntityId} / {entity.Description} ({entity.Score})");
            }
        }
示例#4
0
        /// <summary>
        /// Get all tag for this picture
        /// </summary>
        /// <param name="imageFile">Picture base 64</param>
        /// <param name="extension">Extension picture</param>
        /// <returns>All tag with over 70% of prediction</returns>
        public async Task <List <EntityAnnotation> > GetTags(string imageFile, string extension)
        {
            IReadOnlyList <EntityAnnotation> labels = await clientGoogle.DetectLabelsAsync(Image.FromBytes(ImageConverter.Base64ToByte(imageFile.Replace($"data:image/{extension};base64,", ""))));

            return(labels.Where(l => l.Score * 100 >= 70).ToList());
        }