我试图从图像中扫描文本,但如果不使用S3存储桶,就找不到源代码。这是我找到的唯一的源代码,但是它使用了一个S3。我在这个项目中使用python。在
https://docs.aws.amazon.com/rekognition/latest/dg/text-detecting-text-procedure.html
import boto3
if __name__ == "__main__":
bucket='bucket'
photo='text.png'
client=boto3.client('rekognition')
response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}})
textDetections=response['TextDetections']
print ('Detected text')
for text in textDetections:
print ('Detected text:' + text['DetectedText'])
print ('Confidence: ' + "{:.2f}".format(text['Confidence']) + "%")
print ('Id: {}'.format(text['Id']))
if 'ParentId' in text:
print ('Parent Id: {}'.format(text['ParentId']))
print ('Type:' + text['Type'])
print
在这里找到一个Can I use Amazon Rekognition without an S3 bucket?并运行它与我需要的不同,因为它只检测标签。在
Rekognition API中的
DetectText
方法(对于boto,detect_text
)可以采用以下参数之一:因此,如果不使用s3bucket,则必须提供它的字节。在docs中没有提到第三种方法。输入结构如下所示:
而且,要获取非S3映像的字节流,可以从this answer复制实现:
^{pr2}$相关问题 更多 >
编程相关推荐