jquery网络摄像头拍照

时间:2012-05-16 15:40:33

标签: jquery html web webcam

我正在尝试使用网络摄像头的jquery插件: http://www.xarg.org/project/jquery-webcam-plugin/ 拍照。

这是我的jquery:

$(document).ready(function(){

    $("#camera").webcam({
            width: 320,
            height: 240,
            mode: "callback",
            swffile: "webcam/jscam_canvas_only.swf",



            onTick: function(remain) {

            if (0 == remain) {
                jQuery("#status").text("Cheese!");
            } else {
                jQuery("#status").text(remain + " seconds remaining...");
            }
            },



            onSave: function(data) {

            var col = data.split(";");
            var img = image;
            var canvas = document.getElementById("canvas");
            var ctx = canvas.getContext("2d");
            for(var i = 0; i < 320; i++) {
                var tmp = parseInt(col[i]);
                img.data[pos + 0] = (tmp >> 16) & 0xff;
                img.data[pos + 1] = (tmp >> 8) & 0xff;
                img.data[pos + 2] = tmp & 0xff;
                img.data[pos + 3] = 0xff;
                pos+= 4;
            }

            if (pos >= 4 * 320 * 240) {
                ctx.putImageData(img, 0, 0);
                pos = 0;
            }
            },



            onCapture: function () {

            jQuery("#flash").css("display", "block");
            jQuery("#flash").fadeOut("fast", function () {
                    jQuery("#flash").css("opacity", 1);
            });

            webcam.save();
            },






            debug: function (type, string) {
            $("#status").html(type + ": " + string);
            },





            onLoad: function() {

            var cams = webcam.getCameraList();
            for(var i in cams) {
                jQuery("#cams").append("<li>" + cams[i] + "</li>");
            }
            }


    }); 

});

这是我的HTML:

<div id="camera"></div>
<canvas id="canvas" height="240" width="320"></canvas>

<div class="menu"><a href="javascript:webcam.capture();changeFilter();void(0);"><p class="menutext">Maak foto</p></a></div>

我收到以下错误:

Uncaught TypeError: Object #<Object> has no method 'capture'

有人知道我需要做什么吗?

0 个答案:

没有答案