Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » OpenCV image to JS blob image
- Chiroyce
-
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.
- ehx
-
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
So just send the binary image data to the client over websocket, then construct the blob 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.
- Discussion Forums
- » Advanced Topics
-
» OpenCV image to JS blob image