/// <summary>
        /// Recognize image text from some url. BMP, TIFF formats are supported now.
        /// </summary>
        /// <param name="url">The image file url.</param>
        /// <param name="language">Language of document to recogniize.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageTextFromUrl(string url, OCRLanguages language, bool useDefaultDictionaries)
        {
            string apiUrl = string.Format(@"ocr/recognize?url={0}&language={1}&useDefaultDictionaries={2}", url, language, useDefaultDictionaries);

            JObject jObject = JObject.Parse(ServiceController.Post(apiUrl, AppSid, AppKey));
            OCRResponse ocrResponse = jObject.ToObject<OCRResponse>();
            return ocrResponse;
        }
        /// <summary>
        /// Recognize image text. BMP, TIFF formats are supported now.
        /// </summary>
        /// <param name="inputFilePath">Input BMP or TIFF file that will be passed as request body</param>
        /// <param name="language">Language of document to recogniize.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageText(string inputFilePath, OCRLanguages language, bool useDefaultDictionaries)
        {
            string apiUrl = string.Format(@"ocr/recognize?language={0}&useDefaultDictionaries={1}", language, useDefaultDictionaries);

            JObject jObject = JObject.Parse(ServiceController.Post(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath)));
            OCRResponse ocrResponse = jObject.ToObject<OCRResponse>();
            return ocrResponse;
        }
Exemple #3
0
        /// <summary>
        /// Recognize image text from some url. BMP, TIFF formats are supported now.
        /// </summary>
        /// <param name="url">The image file url.</param>
        /// <param name="language">Language of document to recogniize.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageTextFromUrl(string url, OCRLanguages language, bool useDefaultDictionaries)
        {
            string apiUrl = string.Format(@"ocr/recognize?url={0}&language={1}&useDefaultDictionaries={2}", url, language, useDefaultDictionaries);

            JObject     jObject     = JObject.Parse(ServiceController.Post(apiUrl, AppSid, AppKey));
            OCRResponse ocrResponse = jObject.ToObject <OCRResponse>();

            return(ocrResponse);
        }
Exemple #4
0
        /// <summary>
        /// Recognize image text. BMP, TIFF formats are supported now.
        /// </summary>
        /// <param name="inputFilePath">Input BMP or TIFF file that will be passed as request body</param>
        /// <param name="language">Language of document to recogniize.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageText(string inputFilePath, OCRLanguages language, bool useDefaultDictionaries)
        {
            string apiUrl = string.Format(@"ocr/recognize?language={0}&useDefaultDictionaries={1}", language, useDefaultDictionaries);

            JObject     jObject     = JObject.Parse(ServiceController.Post(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath)));
            OCRResponse ocrResponse = jObject.ToObject <OCRResponse>();

            return(ocrResponse);
        }
        /// <summary>
        /// Recognize image text, language and text region can be selected, default dictionaries can be used for correction.
        /// </summary>
        /// <param name="name">Name of the file to recognize. BMP, TIFF formats are supported now.</param>
        /// <param name="language">Language of the document. e.g. language=english</param>
        /// <param name="rectX">Top left point X coordinate of  to recognize text inside.</param>
        /// <param name="rectY">Top left point Y coordinate of  to recognize text inside.</param>
        /// <param name="rectWidth">Width of  to recognize text inside.</param>
        /// <param name="rectHeight">Height of  to recognize text inside.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <param name="folder">Image's folder.</param>
        /// <param name="storage">Image's storage.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageText(string name, OCRLanguages language, int rectX, int rectY, int rectWidth, int rectHeight, bool useDefaultDictionaries, string folder, string storage = "")
        {
            // GET 	ocr/{name}/recognize?appSID={appSID}&language={language}&rectX={rectX}&rectY={rectY}&rectWidth={rectWidth}&rectHeight={rectHeight}&useDefaultDictionaries={useDefaultDictionaries}&storage={storage}&folder={folder}

            string apiUrl = string.Format(@"ocr/{0}/recognize?language={1}&rectX={2}&rectY={3}&rectWidth={4}&rectHeight={5}&useDefaultDictionaries={6}&storage={7}&folder={8}",
                                            name, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder);

            JObject jObject = JObject.Parse(ServiceController.Get(apiUrl, AppSid, AppKey));
            OCRResponse ocrResponse = jObject.ToObject<OCRResponse>();
            return ocrResponse;
        }
Exemple #6
0
        /// <summary>
        /// Recognize image text, language and text region can be selected, default dictionaries can be used for correction.
        /// </summary>
        /// <param name="name">Name of the file to recognize. BMP, TIFF formats are supported now.</param>
        /// <param name="language">Language of the document. e.g. language=english</param>
        /// <param name="rectX">Top left point X coordinate of  to recognize text inside.</param>
        /// <param name="rectY">Top left point Y coordinate of  to recognize text inside.</param>
        /// <param name="rectWidth">Width of  to recognize text inside.</param>
        /// <param name="rectHeight">Height of  to recognize text inside.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries for result correction.</param>
        /// <param name="folder">Image's folder.</param>
        /// <param name="storage">Image's storage.</param>
        /// <returns>OCRResponse object</returns>
        public OCRResponse RecognizeImageText(string name, OCRLanguages language, int rectX, int rectY, int rectWidth, int rectHeight, bool useDefaultDictionaries, string folder, string storage = "")
        {
            // GET  ocr/{name}/recognize?appSID={appSID}&language={language}&rectX={rectX}&rectY={rectY}&rectWidth={rectWidth}&rectHeight={rectHeight}&useDefaultDictionaries={useDefaultDictionaries}&storage={storage}&folder={folder}

            string apiUrl = string.Format(@"ocr/{0}/recognize?language={1}&rectX={2}&rectY={3}&rectWidth={4}&rectHeight={5}&useDefaultDictionaries={6}&storage={7}&folder={8}",
                                          name, language, rectX, rectY, rectWidth, rectHeight, useDefaultDictionaries, storage, folder);

            JObject     jObject     = JObject.Parse(ServiceController.Get(apiUrl, AppSid, AppKey));
            OCRResponse ocrResponse = jObject.ToObject <OCRResponse>();

            return(ocrResponse);
        }
        static void Main()
        {
            string       url      = "http://cdn.aspose.com/tmp/ocr-sample.bmp";
            OCRLanguages language = OCRLanguages.English;
            bool         useDefaultDictionaries = true;

            OCRResponse r = Common.OCRService.RecognizeImageTextFromUrl(
                url,
                language,
                useDefaultDictionaries
                );

            foreach (Part p in r.PartsInfo.Parts)
            {
                Console.WriteLine(p.Text);
            }

            Common.Pause();
        }
Exemple #8
0
        static void Main()
        {
            string dataDir   = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            string input     = "Sample3.bmp";
            string inputPath = dataDir + input;

            OCRLanguages language               = OCRLanguages.English;
            int          rectX                  = 10;
            int          rectY                  = 10;
            int          rectWidth              = 600;
            int          rectHeight             = 400;
            bool         useDefaultDictionaries = true;

            Common.StorageService.File.UploadFile(
                inputPath,
                input,
                storage: Common.STORAGE
                );

            OCRResponse r = Common.OCRService.RecognizeImageText(
                input,
                language,
                rectX,
                rectY,
                rectWidth,
                rectHeight,
                useDefaultDictionaries,
                Common.FOLDER,
                Common.STORAGE
                );

            foreach (Part p in r.PartsInfo.Parts)
            {
                Console.WriteLine(p.Text);
            }

            Common.Pause();
        }