I need to pass a cropped image to the Computer Vision client in Azure, either as a stream or a url. I'm using PIL to crop the image based on some bounding box values. img1 stores the cropped image
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)
OR
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)
When I run the code above I get the error: raise AttributeError(name) AttributeError: name
Previously, when i uploaded the image from my files, I used this code which worked well:
with open('filepath\filename.jpg', 'rb') as bg_image:
colour_analysis = computervision_client.analyze_image_in_stream(bg_image, remote_image_features)
How do I pass the cropped image to the Azure Client?