示例#1
0
        // GET: Pictures/Play/5
        public async Task <IActionResult> Play(int?id, int?[] type)
        {
            var userId = GetCookie("key");

            if (id == null)
            {
                return(NotFound());
            }

            List <VisualFeatureTypes> featureTypes = new List <VisualFeatureTypes>();

            if (type.Count() > 0)
            {
                foreach (var itemType in type)
                {
                    var xpto = (VisualFeatureTypes)(Convert.ToInt32(itemType));
                    featureTypes.Add(xpto);
                }
            }
            else
            {
                featureTypes = features;
            }


            var picture = await _context.Picture.FirstOrDefaultAsync(m => m.PictureId == id);

            if (picture == null)
            {
                return(NotFound());
            }

            PictureIAService picServ = new PictureIAService(_computerVisionEndpoint, _computerVisionKey);

            string url;

            if (picture.Storage)
            {
                url = _azureStorageConfig.Url + _azureStorageConfig.ImageContainer + "/" + picture.Address;
            }
            else
            {
                url = picture.Address;
            }

            var response = await picServ.AnalyzeRemoteAsync(url, featureTypes);

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(response);

            ViewBag.ImageUrl = url;
            ViewBag.features = json;
            ViewBag.response = response;

            PlayViewModel viewModel = new PlayViewModel();

            viewModel.AnalysisReturn = response;
            viewModel.Picture        = picture;

            return(View(viewModel));
        }
示例#2
0
        // GET: Pictures/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var picture = await _context.Picture
                          .FirstOrDefaultAsync(m => m.PictureId == id);

            if (picture == null)
            {
                return(NotFound());
            }

            PictureIAService picServ = new PictureIAService(_computerVisionEndpoint, _computerVisionKey);

            string url;

            if (picture.Storage)
            {
                url = _azureStorageConfig.Url + _azureStorageConfig.ImageContainer + "/" + picture.Address;
            }
            else
            {
                url = picture.Address;
            }

            var response = await picServ.AnalyzeRemoteAsync(url, features);

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(response);

            ViewBag.ImageUrl = url;
            ViewBag.features = json;


            return(View(picture));
        }