Last active
December 3, 2020 19:28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aspose.OCR-Cloud-Python-SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-python/ | |
file_name = "5.png" | |
src = os.path.join(TestHelper.get_local_folder(), file_name) | |
regions = [ | |
OCRRegion(OCRRect(243, 308, 2095, 964), 0), | |
OCRRegion(OCRRect(240, 1045, 2108, 1826), 1), | |
OCRRegion(OCRRect(237, 1916, 2083, 3180), 2), | |
] | |
request_data = OCRRequestData(regions, LanguageGroup.FRENCH, False) | |
try: | |
res = self.api.post_recognize_regions_from_content(request_data, | |
src) # type: asposeocrcloud.models.OcrResponse | |
self.assertTrue(isinstance(res, asposeocrcloud.models.OcrResponse), | |
"Error recognize image regions from Storage") | |
print(res.text) | |
except ApiException as ex: | |
print("Exception") | |
print("Info: " + str(ex)) | |
raise ex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-python/ | |
import os | |
import asposeocrcloud.api.storage_api | |
from asposeocrcloud.configuration import Configuration | |
from asposeocrcloud.api.ocr_api import OcrApi | |
from asposeocrcloud.models import OCRRect, OCRRegion, OCRRequestData, OCRRequestDataStorage, LanguageGroup | |
from asposeocrcloud.rest import ApiException | |
import json as json | |
class RecognizeFromContent(object): | |
def __init__(self): | |
# Setup CAD and Storage API clients | |
with open("config.json") as f: | |
server_file_info = json.load(f) | |
config = Configuration( apiKey=server_file_info['AppKey'], | |
appSid=server_file_info['AppSid']) | |
self.ocr_api = OcrApi(config) | |
def recognize_text(self): | |
file_name = "5.png" | |
src = os.path.join(os.path.abspath("data/"), file_name) | |
try: | |
res = self.ocr_api.post_recognize_from_content(src) # type: asposeocrcloud.models.OcrResponse | |
return res.text | |
except ApiException as ex: | |
print("Exception") | |
print("Info: " + str(ex)) | |
raise ex | |
obj=RecognizeFromContent() | |
print(obj.recognize_text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-python/ | |
import asposeocrcloud.api.storage_api | |
from asposeocrcloud.configuration import Configuration | |
from asposeocrcloud.api.ocr_api import OcrApi | |
from asposeocrcloud.models import OCRRect, OCRRegion, OCRRequestData, OCRRequestDataStorage, LanguageGroup | |
import json as json | |
class RecognizeFromStorage(object): | |
def __init__(self): | |
# Setup CAD and Storage API clients | |
with open("config.json") as f: | |
server_file_info = json.load(f) | |
config = Configuration( apiKey=server_file_info['AppKey'], | |
appSid=server_file_info['AppSid']) | |
self.ocr_api = OcrApi(config) | |
self.storage_api= asposeocrcloud.api.storage_api.StorageApi(config) | |
def recognize_text(self): | |
self.storage_api.upload_file("5.png", r"data\5.png") | |
res = self.ocr_api.get_recognize_from_storage("5.png") | |
return res.text | |
obj=RecognizeFromStorage() | |
print(obj.recognize_text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-python/ | |
import os | |
import asposeocrcloud.api.storage_api | |
from asposeocrcloud.configuration import Configuration | |
from asposeocrcloud.api.ocr_api import OcrApi | |
from asposeocrcloud.models import OCRRect, OCRRegion, OCRRequestData, OCRRequestDataStorage, LanguageGroup | |
from asposeocrcloud.rest import ApiException | |
import json as json | |
class RecognizeFromURL(object): | |
def __init__(self): | |
# Setup CAD and Storage API clients | |
with open("config.json") as f: | |
server_file_info = json.load(f) | |
config = Configuration( apiKey=server_file_info['AppKey'], | |
appSid=server_file_info['AppSid']) | |
self.ocr_api = OcrApi(config) | |
def recognize_text(self): | |
url = "https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png" | |
try: | |
res = self.ocr_api.post_recognize_from_url(url) # type: asposeocrcloud.models.OcrResponse | |
return res.text | |
except ApiException as ex: | |
print("Exception") | |
print("Info: " + str(ex)) | |
raise ex | |
obj=RecognizeFromURL() | |
print(obj.recognize_text()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment