Exemplo n.º 1
0
        public async Task <string> ProcessRecipe()
        {
            string jsonObject = await Request.Content.ReadAsStringAsync();

            //byte[] image = await Request.Content.ReadAsByteArrayAsync();

            //if (image == null)
            //	image = File.ReadAllBytes(@"C:\test\new\IMG_0030.jpg");
            //OCR.Space.OCRSpaceMain ocrSpace = new OCR.Space.OCRSpaceMain();
            //string jsonObject = ocrSpace.ProcessPicture(image, "TestImageName.jpg");

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Recipe recipe = serializer.Deserialize <Recipe>(jsonObject);

            if (recipe.OCRExitCode != 1)
            {
                return(null);
            }

            TextOverlay overlay = recipe.ParsedResults[0].TextOverlay;

            overlay.ComputeExtraFields();

            string htmlOutput = RecipeHTMLConverter.ConvertRecipeToHTML(recipe);

            string jsonOutput = ProcessRecipe(Encoding.ASCII.GetBytes(htmlOutput));

            return(jsonOutput);
        }
Exemplo n.º 2
0
        public async Task <string> ProcessRecipe()
        {
            var jsonRequest = await Request.Content.ReadAsStringAsync();

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Recipe recipe = serializer.Deserialize <Recipe>(jsonRequest);

            if (recipe.OCRExitCode != 1)
            {
                return(recipe.ErrorMessage);
            }

            string htmlOutput = RecipeHTMLConverter.ConvertRecipeToHTML(recipe);

            return(ProcessRecipe(htmlOutput));
        }