2013-10-09 54 views
1

我必须使用Opencv在python服务器上处理图像。斑去蟒蛇服务器,但我无法弄清楚如何将这个BLOB转换回图像与OpenCV的如何处理blob通过websocket通过JavaScript发送回python服务器?

//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) 

请帮我想出解决办法

+0

尝试查看开发人员工具中的网络选项卡,以查看blob是如何通过websocket发送的。 – Musa

+0

它可能是b64编码,之后使用imdecode从jpeg制作cv图像 – berak

回答

1

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

相关问题