static string RecognizeRegionsFromContent(Configuration conf) { List <OCRRegion> mImage5PngRegions = new List <OCRRegion>() { new OCRRegion() { Order = 0, Rect = new OCRRect(243, 308, 2095, 964) }, new OCRRegion() { Order = 1, Rect = new OCRRect(240, 1045, 2108, 1826) }, new OCRRegion() { Order = 2, Rect = new OCRRect(237, 1916, 2083, 3180) } }; string name = "5.png"; using (FileStream fs = File.OpenRead(name)) { OcrApi api = new OcrApi(conf); OCRRegionsRequestData requestData = new OCRRegionsRequestData() { Language = LanguageEnum.English, Regions = mImage5PngRegions }; OCRResponse response = api.OcrRegionsFromContent(requestData, fs); return(response.Text); } }
public OCRResponse gooleVisionTextDecoderApi(OCRResponse objResp) { TpServiceLog tpServiceLog = new TpServiceLog(); //objResp = new OCRResponse(); tpServiceLog.ServiceRequest = Newtonsoft.Json.JsonConvert.SerializeObject(objResp); TransactLog transactLog = new TransactLog(); transactLog.SerivceTraceID = tpServiceLog.ServiceTraceID = objResp.ServiceTraceID; transactLog.UserName = objResp.UserName; string Message = ValidateUserAuth(transactLog); if (Message != "" && Message != null) { objResp.ErrorMessage = Message; return(objResp); } if (!string.IsNullOrEmpty(objResp.Filedata)) { objResp = commonBusiness.gooleVisionTextDecoderApi(objResp); } else { objResp = new OCRResponse(); objResp.ErrorMessage = "Image not found"; objResp.ErrorCode = 1; } tpServiceLog.ServiceResponse = Newtonsoft.Json.JsonConvert.SerializeObject(objResp); commonBusiness.CreateServiceLog(tpServiceLog); return(objResp); }
static string RecognizeRegionsFromUrl(Configuration conf) { string urlToFile = @"https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png"; List <OCRRegion> mImageBook_of_Abraham_FirstPagePngRegions = new List <OCRRegion>() { new OCRRegion() { Order = 0, Rect = new OCRRect(209, 28, 283, 39) }, new OCRRegion() { Order = 1, Rect = new OCRRect(24, 114, 359, 185) }, new OCRRegion() { Order = 2, Rect = new OCRRect(21, 201, 356, 451) }, new OCRRegion() { Order = 3, Rect = new OCRRect(21, 464, 359, 558) } }; OcrApi api = new OcrApi(conf); OCRRegionsRequestData requestData = new OCRRegionsRequestData() { Regions = mImageBook_of_Abraham_FirstPagePngRegions }; OCRResponse response = api.OcrRegionsFromUrl(requestData, urlToFile); return(response.Text); }
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); }
public object Any(OCRRequest request) { OCRResponse myResponse = new OCRResponse(); if (request.Base64UploadFile == null || string.IsNullOrWhiteSpace(request.Base64UploadFile.ToString())) { myResponse.jsonResponse = "There was no file attached or no file name was specified."; return(myResponse); } try { // get the image data and save to local storage string base64ImgStr = request.Base64UploadFile.ToString().Split(',')[1]; byte[] tmpBytes = Convert.FromBase64String(base64ImgStr); Image image = (Bitmap)((new ImageConverter()).ConvertFrom(tmpBytes)); // now do the OCR junk here var ocr = new Tesseract(); ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,/"); ocr.Init(@"C:\source\innovation\Content\tessdata", "eng", false); var resizedImage = (Bitmap)Resize(image, (3000), (3000), false); resizedImage.SetResolution(300, 300); var blackAndWhiteImage = BlackAndWhite(resizedImage, new Rectangle(0, 0, resizedImage.Width, resizedImage.Height)); var result = ocr.DoOCR(blackAndWhiteImage, Rectangle.Empty); OCRRawDataModel dataItems = new OCRRawDataModel(); dataItems.DataList = new List <OCRRawDataModel.RawDataItem>(); foreach (Word word in result) { var item = new OCRRawDataModel.RawDataItem(); item.Value = word.Text; item.Confidence = (int)word.Confidence; item.LineIndex = word.LineIndex; dataItems.DataList.Add(item); } var mapper = new IdentificationCardMapper(); var mappedObjects = mapper.MapDriversLicenseData(dataItems); myResponse.jsonResponse = JsonConvert.SerializeObject(mappedObjects); // cleanup image.Dispose(); resizedImage.Dispose(); ocr.Dispose(); } catch (Exception ex) { // i don't know what to do here... myResponse.jsonResponse = ex.Message; } return(myResponse); }
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); }
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); }
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) + " .................."); } }
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); } }
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 }
/// <summary> /// Recognize image text from some url if provided or from the request body content /// </summary> /// <param name="request">Request. <see cref="PostOcrFromUrlOrContentRequest" /></param> /// <returns><see cref="OCRResponse"/></returns> public OCRResponse PostOcrFromUrlOrContent(PostOcrFromUrlOrContentRequest request) { // create path and map variables var resourcePath = this.mConfiguration.GetApiRootUrl() + "/ocr/recognize"; resourcePath = Regex .Replace(resourcePath, "\\*", string.Empty) .Replace("&", "&") .Replace("/?", "?"); var formParams = new Dictionary <string, object>(); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "url", request.url); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "language", request.language); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "resultType", request.resultType); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "skewCorrect", request.skewCorrect); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "spellCheck", request.spellCheck); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "dsrMode", request.dsrMode); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "dsrConfidence", request.dsrConfidence); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "makeContrastCorrection", request.contrastCorrection); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "makeImageUpscaling", request.imageUpscale); if (request.File != null) { formParams.Add("file", this.apiInvoker.ToFileInfo(request.File, "File")); } try { return(this.apiInvoker.InvokeApi <OCRResponse>( resourcePath, "POST", null, null, formParams)); } catch (ApiException ex) { OCRResponse ocrRespose = new OCRResponse(); ocrRespose.Status = "1"; ocrRespose.StatusMessage = "PipelineException"; return(ocrRespose); } catch (TimeoutException) { OCRResponse ocrRespose = new OCRResponse(); ocrRespose.Status = "2"; ocrRespose.StatusMessage = "TimeOutException"; return(ocrRespose); } }
static string RecognizeFromStorage(Configuration conf) { string name = "10.png"; OcrApi api = new OcrApi(conf); FileApi fileApi = new FileApi(conf /* or AppSid & AppKey*/); fileApi.UploadFile(new UploadFileRequest(name, System.IO.File.OpenRead(name))); GetRecognizeDocumentRequest request = new GetRecognizeDocumentRequest(name); OCRResponse response = api.GetRecognizeDocument(request); return(response.Text); }
/// <summary> /// Recognize image text, language and text region can be selected /// </summary> /// <param name="request">Request. <see cref="GetRecognizeDocumentRequest" /></param> /// <returns><see cref="OCRResponse"/></returns> public OCRResponse GetRecognizeDocument(GetRecognizeDocumentRequest request) { // verify the required parameter 'name' is set if (request.name == null) { throw new ApiException(400, "Missing required parameter 'name' when calling GetRecognizeDocument"); } // create path and map variables var resourcePath = this.mConfiguration.GetApiRootUrl() + "/ocr/{name}/recognize"; resourcePath = Regex .Replace(resourcePath, "\\*", string.Empty) .Replace("&", "&") .Replace("/?", "?"); resourcePath = UrlHelper.AddPathParameter(resourcePath, "name", request.name); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.storage); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "folder", request.folder); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "language", request.language); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "resultType", request.resultType); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "skewCorrect", request.skewCorrect); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "spellCheck", request.spellCheck); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "dsrMode", request.dsrMode); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "dsrConfidence", request.dsrConfidence); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "makeContrastCorrection", request.contrastCorrection); try { return(this.apiInvoker.InvokeApi <OCRResponse>( resourcePath, "GET", null, null, null)); } catch (TimeoutException) { OCRResponse ocrRespose = new OCRResponse(); ocrRespose.Status = "2"; ocrRespose.StatusMessage = "TimeOutException"; return(ocrRespose); } }
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(); }
/// <summary> /// Recognize specific regions of image located at Aspose Storage. /// Use StorageApi to upload your files. <see cref="StorageApi"/> /// </summary> /// <param name="requestData">Regions, language and file path in Aspose Storage. <see cref="OCRRequestData"/></param> /// <returns><see cref="OCRResponse"/></returns> public OCRResponse OcrRegionsFromStorage(OCRRequestDataStorage requestData) { var requestUrl = BuildUrl("recognize-regions-url"); var formParams = new Dictionary <string, object> { { "requestData", requestData } }; try { return(this.apiInvoker.InvokeApi <OCRResponse>(requestUrl, "POST", null, null, formParams)); } catch (TimeoutException) { OCRResponse ocrRespose = new OCRResponse(); ocrRespose.Status = "2"; ocrRespose.StatusMessage = "TimeOutException"; return(ocrRespose); } }
static void Main() { string dataDir = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); string input = "sample1.bmp"; string inputPath = dataDir + input; OCRResponse r = Common.OCRService.RecognizeImageText( inputPath, OCRLanguages.English, true ); foreach (Part p in r.PartsInfo.Parts) { Console.WriteLine(p.Text); } Common.Pause(); }
/// <summary> /// Recognize specific regions of image from File Stream /// </summary> /// <param name="requestData">Regions, language and some options. <see cref="OCRRequestData"/></param> /// <param name="file">Local file stream</param> /// <returns><see cref="OCRResponse"/></returns> public OCRResponse OcrRegionsFromContent(OCRRequestData requestData, Stream file) { var requestUrl = BuildUrl("recognize-regions-content"); var fileInfo = this.apiInvoker.ToFileInfo(file, "File"); var formParams = new Dictionary <string, object> { { "file", fileInfo }, { "requestData", requestData } }; try { return(this.apiInvoker.InvokeApi <OCRResponse>(requestUrl, "POST", null, null, formParams)); } catch (TimeoutException) { OCRResponse ocrRespose = new OCRResponse(); ocrRespose.Status = "2"; ocrRespose.StatusMessage = "TimeOutException"; return(ocrRespose); } }
public string Convert(Stream file, string fileName, string language) { LanguageEnum lg = LanguageEnum.English; System.Enum.TryParse <LanguageEnum>(language, true, out lg); UploadFileRequest uploadFileRequest = new UploadFileRequest() { path = fileName, File = file }; OCRFileApi.UploadFile(uploadFileRequest); GetRecognizeDocumentRequest request = new GetRecognizeDocumentRequest(name: fileName, language: lg); OCRResponse response = OCRCloudApi.GetRecognizeDocument(request); OCRFileApi.DeleteFile(new DeleteFileRequest(path: fileName)); return(response.Text); }
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 }
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(); }
static string RecognizeRegionsFromStorage(Configuration conf) { List <OCRRegion> mImage5PngRegions = new List <OCRRegion>() { new OCRRegion() { Order = 0, Rect = new OCRRect(243, 308, 2095, 964) }, new OCRRegion() { Order = 1, Rect = new OCRRect(240, 1045, 2108, 1826) }, new OCRRegion() { Order = 2, Rect = new OCRRect(237, 1916, 2083, 3180) } }; string name = "5.png"; using (FileStream fs = File.OpenRead(name)) { OcrApi api = new OcrApi(conf); FileApi fileApi = new FileApi(conf /* or AppSid & AppKey*/); fileApi.UploadFile(new UploadFileRequest(name, System.IO.File.OpenRead(name))); OCRRegionsRequestDataStorage requestData = new OCRRegionsRequestDataStorage() { Language = LanguageEnum.German, Regions = mImage5PngRegions, FileName = name }; OCRResponse response = api.OcrRegionsFromContent(requestData, fs); return(response.Text); } }
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 OCR_Tests() { OCRResponse ocrResponse = ocrService.RecognizeImageText("ocr-sample.bmp", OCRLanguages.English, 0, 0, 500, 300, false, Utils.CloudStorage_Input_Folder); OCRResponse ocrResponse2 = ocrService.RecognizeImageTextFromUrl("http://cdn.aspose.com/tmp/ocr-sample.bmp", OCRLanguages.English, false); OCRResponse ocrResponse3 = ocrService.RecognizeImageText(Utils.Local_Input_Path + "ocr-sample.bmp", OCRLanguages.English, false); }
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 }
public OCRResponse gooleVisionTextDecoderApi(OCRResponse objResp) { AIA.Life.Business.Common.CommonBusiness obj = new AIA.Life.Business.Common.CommonBusiness(); objResp = obj.gooleVisionTextDecoderApi(objResp); return(objResp); }