Can't output CV2 processed image to Blob

Nathan Carns 196 Reputation points
2021-06-29T12:53:09.177+00:00

Hi.

I have an Azure Function (Python) with a Blob trigger and a Blob output. Image gets uploaded to a container, triggering the function that detects objects in the picture and draws a rectangle highlighting the objects using OpenCV2. When the image is processed, I want to send it to the container. But when I want to output the image using outBlob.set(image), it errors out and says it has something to do with the CV2 image format.

How do I change the image to a format that can be sent to the Blob container? I loaded the image using imutils (url_to_image) where the url is the blob uri. Then processed it and tried to send it as output to a container.

Thank you.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
{count} votes

Accepted answer
  1. Nathan Carns 196 Reputation points
    2021-06-30T10:47:27.233+00:00

    Thank you the reply.

    The CV2 image format is of type numpy.ndarray, and apparently I couldn't send it as output to a blob storage. I fixed that by (re-)encoding the image to the same format as it came in (JPEG or PNG) and that worked out fine. Not sure if this is a common solution or whether there's something more convenient, but at the moment, it looks like it's working.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.