开发者

Tornado with jQuery Webcam Plugin Problem

开发者 https://www.devze.com 2023-03-29 21:13 出处:网络
I\'m using Tornado Webserver and the jQuery Webcam Plugin. Everything is going fine except that I don\'t think i\'m getting the raw data properly. I\'m getting \"FFD8FFE000104A46494600010100000100010

I'm using Tornado Webserver and the jQuery Webcam Plugin.

Everything is going fine except that I don't think i'm getting the raw data properly. I'm getting "FFD8FFE000104A46494600010100000100010000FFDB0084000503040404030504040405050506070C08070707070F0B0B090C110F1212110F111113161C1713141A1511111821181A1D1开发者_JAVA百科D1F1F1F13172224221E241C1E1F1E010505050706070E08080E1E1411141E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1" for my data.

frontend:

$("#camera").webcam({width: 320,
            height: 240,
            mode: "save",
            swffile: "/static/js/jscam.swf",
            onTick: function() {
            alert('OnTick');},
            onCapture: function() {
                webcam.capture();
                var x = webcam.save('/saveimage');
            },
            onDebug: function(type, string) {
            alert('error');
            alert(type + ": " + string);}, 
        });

backend:

filecontent = self.request.body f = open('static/studentphotos/'+ filename +'.jpg','w') f.write(filecontent) f.close()"


Using your data as x, notice the JFIF in the output from unhexlify:

In [88]: binascii.unhexlify(x[:-1])
Out[88]: '\xff\xd8\xff\xe0\x00\x10JFIF...'

So it appears the data is a JPEG that needs to be unhexlified. Therefore try:

import binascii
filecontent = self.request.body 
with open('static/studentphotos/'+ filename +'.jpg','w')  as f:
    f.write(binascii.unhexlify(filecontent))
0

精彩评论

暂无评论...
验证码 换一张
取 消