public void GetImageDescription(MedicineImage Image)
        {
            string apiKey    = "acc_c8ca6e79732e57a";
            string apiSecret = "8be9e6d5b65cdd77fd3f2142b95e5d50";
            string image     = Image.ImageUrl;

            string basicAuthValue = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(String.Format("{0}:{1}", apiKey, apiSecret)));

            var client = new RestClient("https://api.imagga.com/v2/tags");

            client.Timeout = -1;

            var request = new RestRequest(Method.POST);

            request.AddHeader("Authorization", String.Format("Basic {0}", basicAuthValue));
            request.AddFile("image", image);

            IRestResponse response    = client.Execute(request);
            ImaggaRoot    DetailsTree = JsonConvert.DeserializeObject <ImaggaRoot>(response.Content);

            foreach (var item in DetailsTree.result.tags)
            {
                Image.Description.Add(item.tag.en, item.confidence);
            }
        }
예제 #2
0
        public List <string> CheckImage(string URL)
        {
            List <string> Result = new List <string>();

            double        Threshold = 50.0;
            MedicineImage Image     = new MedicineImage(URL);

            Image.Description = new Dictionary <string, double>();

            dal.GetImageDescription(Image);
            foreach (var item in Image.Description)
            {
                if (item.Value >= Threshold)
                {
                    Result.Add(item.Key);
                }
                else
                {
                    break;
                }
            }
            return(Result);
        }
        public ActionResult NotMedicine()
        {
            MedicineImage img = new MedicineImage(string.Empty);

            return(View(img));
        }