[英]Passing PIL cropped image as stream in Azure Computer Vision
我需要將裁剪后的圖像作為流或 url 傳遞給 Azure 中的計算機視覺客戶端。 我正在使用 PIL 根據一些邊界框值裁剪圖像。 img1 存儲裁剪后的圖像
img1 = img.crop((bbox[i][0], bbox[i][1], bbox[i][4], bbox[i][5]))
img1.show()
with open(img1.name, 'rb') as bg_image1:
colour_analysis = computervision_client.analyze_image_in_stream(bg_image1, remote_image_features)
要么
img1 = img.crop((bbox[i][0], bbox[i][1], bbox[i][4], bbox[i][5]))
img1.show()
open_image = open(img1.name, "rb")
colour_analysis = computervision_client.analyze_image_in_stream(open_image, remote_image_features)
當我運行上面的代碼時,出現錯誤:raise AttributeError(name) AttributeError: name
以前,當我從我的文件上傳圖像時,我使用了運行良好的代碼:
with open('filepath\filename.jpg', 'rb') as bg_image:
colour_analysis = computervision_client.analyze_image_in_stream(bg_image, remote_image_features)
如何將裁剪后的圖像傳遞給 Azure 客戶端?
請按照以下 github 示例分析本地圖像。 請參閱 ComputerVisionClient 方法,例如 AnalyzeImageInStreamAsync。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.