public static void Run() { // ExStart:1 // Instantiate Aspose Storage Cloud API SDK StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Instantiate Aspose OCR Cloud API SDK OcrApi ocrApi = new OcrApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set the image file name String name = "Sampleocr.bmp"; // Set the language of the document. String language = "English"; // Set X and Y coordinate to recognize text inside.. int? rectX = 150; int? rectY = 100; //Set Width and Height to recognize text inside. int? rectWidth = 1000; int? rectHeight = 300; //Set the spelling correction is used. bool? useDefaultDictionaries = true; //Set 3rd party cloud storage server (if any) String storage = ""; String folder = ""; try { //upload source file to aspose cloud storage storageApi.PutCreate(name, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + name)); // invoke Aspose.OCR Cloud SDK API to extract text and partsinfo from an image OCRResponse apiResponse = ocrApi.GetRecognizeDocument(name, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder); if (apiResponse != null) { Console.WriteLine("Codetext: " + apiResponse.Text+ "\n"); Console.WriteLine("Extract OCR or HOCR Text from a specific Block, Done!"); } } catch (Exception ex) { Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 // Instantiate Aspose OCR Cloud API SDK OcrApi ocrApi = new OcrApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set the image file name String name = "Sampleocr.bmp"; // Set the image file url. String url = null; // Set the language of the document. String language = "english"; //Set the spelling correction is used. bool? useDefaultDictionaries = true; //Set the local file (if any) byte[] file = System.IO.File.ReadAllBytes(Common.GetDataDir() + name); try { // invoke Aspose.OCR Cloud SDK API to extract image text from URL OCRResponse apiResponse = ocrApi.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); if (apiResponse != null) { Console.WriteLine("Codetext: " + apiResponse.Text+ "\n"); Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage, Done!"); } } catch (Exception ex) { Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 // Instantiate Aspose OCR Cloud API SDK OcrApi ocrApi = new OcrApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set the image file url. String url = "https://dl.dropboxusercontent.com/s/zj35mqdouoxy3rs/Sampleocr.bmp"; // Set the language of the document. String language = "English"; //Set the spelling correction is used. bool? useDefaultDictionaries = true; //Set the local file (if any) byte[] file = null; try { // invoke Aspose.OCR Cloud SDK API to extract image text from URL OCRResponse apiResponse = ocrApi.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); if (apiResponse != null) { Console.WriteLine("Codetext: " + apiResponse.Text+ "\n"); Console.WriteLine("Extract OCR or HOCR Text from Image URL, Done!"); } } catch (Exception ex) { Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void TestGetRecognizeDocument() { OcrApi target = new OcrApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "Sampleocr.bmp"; string language = "english"; int? rectX = null; int? rectY = null; int? rectWidth = null; int? rectHeight = null; bool? useDefaultDictionaries = null; string storage = null; string folder = null; storageApi.PutCreate(name, "", "", System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + name)); Com.Aspose.OCR.Model.OCRResponse actual; actual = target.GetRecognizeDocument(name, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new OCRResponse(), actual.GetType()); }
public void TestPostOcrFromUrlOrContent() { OcrApi target = new OcrApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "Sampleocr.bmp"; string url = null; string language = "english"; bool? useDefaultDictionaries=null; byte[] file = System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + name); Com.Aspose.OCR.Model.OCRResponse actual; actual = target.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new OCRResponse(), actual.GetType()); }
public static void Main(String[] args) { string APIKEY = "xxxxxx"; string APPSID = "xxxxxx"; string BASEPATH = "http://api.aspose.com/v1.1"; ///* //* Working with OCR //* Extract OCR or HOCR Text from Images without using Storage //*/ //OcrApi ocrApi = new OcrApi(APIKEY, APPSID, BASEPATH); //StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); //String fileName = "Sampleocr.bmp"; //String url = null; //String language = "english"; //Boolean useDefaultDictionaries = true; //byte[] file = System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + fileName); //try //{ // //invoke Aspose.PDF Cloud SDK API to append word document // OCRResponse apiResponse = ocrApi.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); // if (apiResponse != null) // { // //download appended document from storage server // Console.WriteLine("Text :: " + apiResponse.Text); // Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage , Done!"); // Console.ReadKey(); // } //} //catch (Exception ex) //{ // System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); //} ///* //* Working with OCR //* Extract OCR or HOCR Text from Images //*/ //OcrApi ocrApi = new OcrApi(APIKEY, APPSID, BASEPATH); //StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); //String fileName = "Sampleocr.bmp"; //String language = ""; //int rectX = 0; //int rectY = 0; //int rectWidth = 0; //int rectHeight = 0; //Boolean useDefaultDictionaries = true; //String storage = ""; //String folder = ""; //try //{ // //upload source file to aspose cloud storage // storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + fileName)); // //invoke Aspose.PDF Cloud SDK API to append word document // OCRResponse apiResponse = ocrApi.GetRecognizeDocument(fileName, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder); // if (apiResponse != null) // { // //download appended document from storage server // Console.WriteLine("Text :: " + apiResponse.Text); // Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage , Done!"); // Console.ReadKey(); // } //} //catch (Exception ex) //{ // System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); //} ///* //* Working with OCR //* Extract OCR or HOCR Text from Images //*/ //OcrApi ocrApi = new OcrApi(APIKEY, APPSID, BASEPATH); //StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); //String fileName = "Sampleocr.bmp"; //String language = "english"; //int rectX = 150; //int rectY = 100; //int rectWidth = 1000; //int rectHeight = 300; //Boolean useDefaultDictionaries = true; //String storage = ""; //String folder = ""; //try //{ // //upload source file to aspose cloud storage // storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + fileName)); // //invoke Aspose.PDF Cloud SDK API to append word document // OCRResponse apiResponse = ocrApi.GetRecognizeDocument(fileName, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder); // if (apiResponse != null) // { // //download appended document from storage server // Console.WriteLine("Text :: " + apiResponse.Text); // Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage , Done!"); // Console.ReadKey(); // } //} //catch (Exception ex) //{ // System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); //} /* * Working with OCR * Extract OCR or HOCR Text from Images without using Storage */ OcrApi ocrApi = new OcrApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); String url = "https://dl.dropboxusercontent.com/s/zj35mqdouoxy3rs/Sampleocr.bmp"; String language = "english"; Boolean useDefaultDictionaries = true; byte[] file = null; try { //invoke Aspose.PDF Cloud SDK API to append word document OCRResponse apiResponse = ocrApi.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); if (apiResponse != null) { //download appended document from storage server Console.WriteLine("Text :: " + apiResponse.Text); Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage , Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } ///* //* Working with OCR //* Extract OCR or HOCR Text from Images without using Storage //*/ //OcrApi ocrApi = new OcrApi(APIKEY, APPSID, BASEPATH); //StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); //String fileName = "Sampleocr.bmp"; //String url = null; //String language = "english"; //Boolean useDefaultDictionaries = true; //byte[] file = System.IO.File.ReadAllBytes("\\temp\\ocr\\resources\\" + fileName); //try //{ // //invoke Aspose.PDF Cloud SDK API to append word document // OCRResponse apiResponse = ocrApi.PostOcrFromUrlOrContent(url, language, useDefaultDictionaries, file); // if (apiResponse != null) // { // //download appended document from storage server // Console.WriteLine("Text :: " + apiResponse.Text); // Console.WriteLine("Extract OCR or HOCR Text from Images without using Storage , Done!"); // Console.ReadKey(); // } //} //catch (Exception ex) //{ // System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); //} //... //End }