Discuss Scratch

Chiroyce
Scratcher
1000+ posts

OpenCV image to JS blob image

I have a server that sends images via a websocket, it currently encodes the image into base64 and sends them to the client, and it is rendered using the data URI scheme. I've seen that base64 adds a lot of unnecessary overhead, so how do I directly convert an OpenCV image into a format that can be used as a blob in JavaScript? I will then convert that blob into a URL and then use it. I do know how to convert an OpenCV image to JPEG bytes, but I don't know how to convert it into a blob.
Chiroyce
Scratcher
1000+ posts

OpenCV image to JS blob image

bump
mbrick2
Scratcher
1000+ posts

OpenCV image to JS blob image

I don't know anything about OpenCV but after some searching I found this. Its the opposite but perhaps it can be reversed.
Chiroyce
Scratcher
1000+ posts

OpenCV image to JS blob image

bump
Chiroyce
Scratcher
1000+ posts

OpenCV image to JS blob image

bump
ehx
New Scratcher
40 posts

OpenCV image to JS blob image

Send the image in some format that you can use as a Uint8Array to the client, and then construct a blob URL from it.

Once you have this data at a Uint8Array, you can then
blob = new Blob(yourUint8array, {type: contentType});
blobUrl = URL.createObjectURL(blob);

So just send the binary image data to the client over websocket, then construct the blob from it.

Powered by DjangoBB