【问题标题】:how to handle blob sent via javascript through websocket back at the python server?如何在python服务器上处理通过websocket通过javascript发送的blob?
【发布时间】:2013-10-09 14:55:28
【问题描述】:

我必须使用 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)

请帮我解决这个问题

【问题讨论】:

  • 尝试查看开发人员工具中的网络选项卡,了解如何通过 websocket 发送 blob。
  • 可能是 b64 编码,然后使用 imdecode 从 jpeg 制作 cv 图像

标签: javascript python google-chrome opencv websocket


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-12-25
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多