是的,AWS Textract支持日语作为OCR的语言。您可以使用AWS SDK来调用Textract API并进行OCR识别。以下是一个使用Python和boto3库的示例代码:
import boto3
def detect_text_from_image(image_path):
# 创建Textract客户端
textract_client = boto3.client('textract', region_name='us-west-2')
# 打开并读取图像文件
with open(image_path, 'rb') as image:
image_bytes = image.read()
# 调用Textract的DetectDocumentText API
response = textract_client.detect_document_text(Document={'Bytes': image_bytes},
FeatureTypes=['TABLES', 'FORMS'])
# 提取文本结果
extracted_text = ""
for item in response['Blocks']:
if item['BlockType'] == 'LINE':
extracted_text += item['Text'] + "\n"
return extracted_text
# 调用示例
image_path = 'path/to/your/image.jpg'
result = detect_text_from_image(image_path)
print(result)
上述代码使用Textract的detect_document_text
方法来检测并提取图像中的文本。您可以将图像文件的路径传递给image_path
变量,并将输出结果保存在result
变量中。最后,使用print
语句打印提取的文本结果。
请注意,您需要将代码中的region_name
参数设置为您所在的AWS区域。确保您已经安装了boto3库,并且已经配置了您的AWS凭证。
此外,您还可以使用其他编程语言和AWS SDK来调用Textract API,方法类似。