Exemple #1
0
        static string RecognizeFromUrl(Configuration conf)
        {
            string      imgUri   = @"https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png";
            OcrApi      api      = new OcrApi(conf);
            var         request  = new PostOcrFromUrlOrContentRequest(null, imgUri, resultType: ResultType.Text);
            OCRResponse response = api.PostOcrFromUrlOrContent(request);

            return(response.Text);
        }
Exemple #2
0
        static string RecognizeFromUrl(Configuration conf)
        {
            string imgUri = @"http://typecast.com/images/uploads/fluid-type-single-column.png";

            OcrApi      api      = new OcrApi(conf);
            var         request  = new PostOcrFromUrlOrContentRequest(null, imgUri);
            OCRResponse response = api.PostOcrFromUrlOrContent(request);

            return(response.Text);
        }
Exemple #3
0
        static string RecognizeFromUrlToPdf(Configuration conf)
        {
            string url = @"https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png";
            OcrApi api = new OcrApi(conf);

            var         request  = new PostOcrFromUrlOrContentRequest(null, url, LanguageEnum.Spanish, ResultType.Pdf, DsrMode.NoDsrNoFilter);
            OCRResponse response = api.PostOcrFromUrlOrContent(request);

            return(response.Text);
        }
Exemple #4
0
        static string RecognizeFromContent(Configuration conf)
        {
            string name = "10.png";

            using (FileStream fs = File.OpenRead(name))
            {
                OcrApi      api      = new OcrApi(conf);
                var         request  = new PostOcrFromUrlOrContentRequest(fs);
                OCRResponse response = api.PostOcrFromUrlOrContent(request);

                return(response.Text);
            }
        }
        static string RecognizeFromContentDeFr(Configuration conf)
        {
            string name = "de_1.jpg";

            using (FileStream fs = File.OpenRead(name))
            {
                OcrApi      api      = new OcrApi(conf);
                var         request  = new PostOcrFromUrlOrContentRequest(fs, "", language: LanguageEnum.German);
                OCRResponse response = api.PostOcrFromUrlOrContent(request);

                return(response.Text);
            }
        }
Exemple #6
0
        static string RecognizeFromContentToPdf(Configuration conf)
        {
            string name = "10.png";

            using (FileStream fs = File.OpenRead(name))
            {
                OcrApi      api      = new OcrApi(conf);
                var         request  = new PostOcrFromUrlOrContentRequest(fs, resultType: ResultType.Pdf, dsrMode: DsrMode.DsrAndFilter);
                OCRResponse response = api.PostOcrFromUrlOrContent(request);

                return(response.Pdf.Substring(0, 30) + " ..................");
            }
        }
Exemple #7
0
        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());
        }
Exemple #8
0
        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
        }
Exemple #10
0
        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
        }