2013-10-09 60 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是如何製作的,然後進行逆向工程

相關問題