2017-06-16 7 views

答えて

2

私の経験上、get_blob_to_bytesメソッドを使用して、blobをバイト配列としてダウンロードし、以下のサンプルコードのようにopencvイメージに変換することができます。

from azure.storage.blob import BlockBlobService 

account_name = '<your-storage-account>' 
account_key = '<your accout key>' 
block_blob_service = BlockBlobService(account_name, account_key) 

container_name = 'mycontainer' 
blob_name = 'test.jpg' 
blob = block_blob_service.get_blob_to_bytes(container_name, blob_name) 

import numpy as np 
import cv2 
# use numpy to construct an array from the bytes 
x = np.fromstring(blob.content, dtype='uint8') 

# decode the array into an image 
img = cv2.imdecode(x, cv2.IMREAD_UNCHANGED) 
print img.shape 

# show it 
cv2.imshow("Image Window", img) 
cv2.waitKey(0) 

希望します。

関連する問題