예제 #1
0
 protected override void GenerateText(object o, EventArgs e)
 {
     try
     {
         string image64    = ImageInBase64.Value.Split(',')[1];
         byte[] byteBuffer = Convert.FromBase64String(image64);
         string text       = GoogleVisionConnectionManager.ExtractText(byteBuffer);
         text = ParseIsbn(text);
         if (text.Length > 0)
         {
             IsbnBox.Text = text;
         }
         IsbnValidator.Validate();
     }
     catch (ArgumentNullException ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
     catch (ExternalException ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
     finally
     {
         WorkingDiv.InnerText = "";
     }
 }
예제 #2
0
            public bool Run(StreamWriter sw)
            {
                using (MemoryStream mStream = new MemoryStream()) {
                    TEST_INPUT_IMAGE.Save(mStream, System.Drawing.Imaging.ImageFormat.Png);
                    if (GoogleVisionConnectionManager.ExtractText(mStream.ToArray()) != TEST_RESULT_TEXT)
                    {
                        sw.WriteLine("GoogleVisionTestExtractText1 failed: Extracted text does not match expected result.");
                        return(false);
                    }
                }

                return(true);
            }
예제 #3
0
            public bool Run(StreamWriter sw)
            {
                using (MemoryStream mStream = new MemoryStream()) {
                    TEST_INPUT_IMAGE.Save(mStream, System.Drawing.Imaging.ImageFormat.Png);
                    if (GoogleVisionConnectionManager.ExtractText(mStream.ToArray()) == null)
                    {
                        sw.WriteLine("GoogleVisionTestConnection failed: No response from API.");
                        return(false);
                    }
                }

                return(true);
            }
예제 #4
0
            public bool Run(StreamWriter sw)
            {
                try
                {
                    GoogleVisionConnectionManager.ExtractText(null);
                }
                catch (NullReferenceException e)
                {
                    return(true);
                }

                sw.WriteLine("GoogleVisionTestNullImage: Call to extractText with null image did not result in exception.");
                return(false);
            }