javascript - 如何处理通过 websocket 通过 javascript 发送回 python 服务器的 blob?

标签 javascript python google-chrome opencv websocket

我必须使用 Opencv 在 python 服务器上处理图像。 blob 转到 python 服务器,但我无法弄清楚如何使用 openCV 将这个 blob 转换回图像

 //this is my javascript function to send image converted to blob, 
//back to my python server
         function () {

             ctx.drawImage(video, 0, 0, 320, 240);
            var data = canvas.get()[0].toDataURL('image/jpeg', 1.0);
             newblob = dataURItoBlob(data);
             ws.send(newblob);

            }

这是我的 python 后端处理

class EchoServerProtocol(WebSocketServerProtocol):

       def onMessage(self, msg, binary):
         img = # here the code to convert blob into the image
         blur = cv2.blur(img, (5, 5))
         hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV)
         msg = hsv
         print "the image:", msg
         #conver the image back to blob and reply back to the websocket
         #havent written the code for this part yet
         self.sendMessage(msg, binary)

请帮我解决这个问题

最佳答案

检查这个 blob 是如何制作的,然后对其进行逆向工程

关于javascript - 如何处理通过 websocket 通过 javascript 发送回 python 服务器的 blob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19275527/

相关文章:

javascript - 如何将 std::function 绑定(bind)到 JavaScript V8?

python - 如何在数据库关系中直接引用表列?

c# - 如何在 C# 中创建 TensorProto?

python - F#编程语言中有类似Python函数装饰器的吗?

javascript - WebKit 相当于 Firefox 的 "moz-chunked-arraybuffer"xhr responseType

javascript - 在 Chrome 中重播 Audio 元素

javascript - Iframe 尝试从安全来源与其顶级框架不同的文档调用 getUserMedia

javascript - Vue 在标记任务之间切换不工作

html - CSS3 Perspective() 动画在鼠标快速移动时表现得很奇怪

javascript - 在 scriptaculous 中固定/取消固定可拖动的 div