简体   繁体   English

如何在opencv python3中读取boto3文件对象

[英]How to read the boto3 file object in opencv python3

I am trying to read the AWS S3 presigned uri file with open-CV. 我正在尝试使用open-CV读取AWS S3 presigned uri文件。 But the read parameter is of NoneType. 但是读取的参数为NoneType。 How to read the boto3 file_obj in opencv and process further? 如何在opencv中读取boto3 file_obj并进一步处理?

import cv2
import boto3

s3Client = boto3.client('s3')
file_path = s3Client.generate_presigned_url('get_object', Params = {'Bucket': 
'www.mybucket.com', 'Key': 'hello.txt'}, ExpiresIn = 100)
img = cv2.imread(file_path)

But it is reading the file as <class 'NoneType'> . 但是它将读取文件为<class 'NoneType'> But I need it to be read by the cv2. 但是我需要cv2读取它。

import urllib2

response = urllib2.urlopen(file_path)
image = response.read()
img = cv2.imread(image)

can you please try this 你可以试试这个吗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM