public IHttpActionResult Post() { if (Request.Content.IsMimeMultipartContent()) { Bitmap bmp = null; Request.Content.LoadIntoBufferAsync().Wait(); var t = Request.Content.ReadAsMultipartAsync <MultipartMemoryStreamProvider>( new MultipartMemoryStreamProvider()).ContinueWith((task) => { MultipartMemoryStreamProvider provider = task.Result; var content = provider.Contents[0]; Stream stream = content.ReadAsStreamAsync().Result; Image image = Image.FromStream(stream); bmp = new Bitmap(stream); return(RealPhotoAnalysis.GetPercentage(bmp)); }); return(Ok(t.Result)); } else { throw new HttpResponseException(Request.CreateResponse( HttpStatusCode.NotAcceptable, "This request is not properly formatted")); } }
public async Task GetRestaurantInformation(String path, PictureBox imageBox2, string username) //todo perkelt imagebox settinima i kita vieta { GooglePlacesApiData googleApiData = new GooglePlacesApiData(); ICalculateLiquidPercentage rpa = new RealPhotoAnalysis(new Image <Emgu.CV.Structure.Bgr, byte>(path)); //ICalculateLiquidPercentage rpa = new SimpleImageAnalysis(new System.Drawing.Bitmap(path)); RealPhotoAnalysis rpa1 = (RealPhotoAnalysis)rpa; imageBox2.Image = rpa1.VisualRepresentation.Bitmap; // GooglePlacesApiResponse responseData = await googleApiData.GetApiResponseData("food"); int percentageOfLiquid = rpa.CalculatePercentageOfLiquid(); Username = username; Date = DateTime.Today; // Name = responseData.results[0].name; // Address = responseData.results[0].vicinity; Percentage = percentageOfLiquid; }