python image对象转换为二进制流,将图像转换为二进制流

该博客讲述了如何在Python中将从HTML5 Canvas获取的Base64编码图像转换为16位像素的二进制流,以便进行像素级别的计算。作者首先使用canvas.toDataURL()将帧转换为Base64图像,然后通过AJAX传递到后端。在Python中,他们尝试将Base64解码后的图像转换为与原始16位像素数据相匹配的格式,但遇到了问题。最终,解决方案是将图像转换为8位灰度图像,然后将8位像素值转换为16位值。
摘要由CSDN通过智能技术生成

There are two sides to my app, on one side I'm using C++ in order to read the frames from a camera using Pleora's EBUS SDK. When this stream is first received, before I convert the buffer to an image, I am able to read the stream 16 bits at a time in order to perform some calculations for each pixel, i.e. there exists a 16 bit chunk of data for each pixel.

Now the second half is a Django web app where I am also presented this video output, this time via an ffmpeg, nginx, hls stream. When the user clicks on the video I want to be able to take the current frame and the coordinates of their click and perform the same calculation as I do above in the C++ portion.

Right now I use an html5 canvas to capture the frame and I use canvas.toDataURL() in order to convert the frame into a base64 encoded image, I then pass the base64 image, the coordinates, and the dimensions of

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值