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 = ""; } }
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); }
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); }
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); }