Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在不使用S3检测图像文本的情况下本地测试AWS的识别_Python_Amazon Web Services_Amazon S3_Amazon Rekognition - Fatal编程技术网

Python 如何在不使用S3检测图像文本的情况下本地测试AWS的识别

Python 如何在不使用S3检测图像文本的情况下本地测试AWS的识别,python,amazon-web-services,amazon-s3,amazon-rekognition,Python,Amazon Web Services,Amazon S3,Amazon Rekognition,我试图从图像中扫描文本,但如果不使用S3存储桶,我就找不到源代码。这是我找到的唯一源代码,但它使用了S3。我在这个项目中使用python 在这里找到一个并运行它与我需要的不同,因为它只检测标签。Rekognition API中的DetectText方法(对于boto,detect\u text)可以采用以下参数之一: 对Amazon S3存储桶中图像的引用 base64编码图像字节 因此,如果不使用S3存储桶,则必须提供其字节。第三种方式在本手册中没有提及。输入结构描述如下: { "I

我试图从图像中扫描文本,但如果不使用S3存储桶,我就找不到源代码。这是我找到的唯一源代码,但它使用了S3。我在这个项目中使用python


在这里找到一个并运行它与我需要的不同,因为它只检测标签。

Rekognition API中的
DetectText
方法(对于boto,
detect\u text
)可以采用以下参数之一:

  • 对Amazon S3存储桶中图像的引用
  • base64编码图像字节
因此,如果不使用S3存储桶,则必须提供其字节。第三种方式在本手册中没有提及。输入结构描述如下:

{
  "Image": { 
    "Bytes": blob,
    "S3Object": { 
      "Bucket": "string",
       "Name": "string",
       "Version": "string"
     }
  }
}
以及,获取非S3图像的字节流;您可以从以下位置复制实现:


用于检测标签的@vahdet可能重复。我认为这与从图像中检测文本不同。
detect\u text
也可以有参数作为
(Image={'Bytes':Image\u binary})
,就像
detect\u标签的情况一样
太棒了!我回来后会在本地测试,谢谢。
{
  "Image": { 
    "Bytes": blob,
    "S3Object": { 
      "Bucket": "string",
       "Name": "string",
       "Version": "string"
     }
  }
}
client = boto3.client('rekognition')

image_path='images/4.jpeg'
image = Image.open(image_path)

stream = io.BytesIO()
image.save(stream,format="JPEG")
image_binary = stream.getvalue()

response = client.detect_text(Image={'Bytes':image_binary})