Skip to content

How can I set the source of an img element as being the picture taken by the webcam? #39

@UlyssesAlves

Description

@UlyssesAlves

Hello.

I am trying to put the image/picture taken by the WebCam in an img element in my page, in the onSave event. How can I do it?

$("#camera").webcam({
width: 320,
height: 240,
mode: "callback",
swffile: "/download/jscam_canvas_only.swf",
onTick: function() {},
onSave: function(data) {
var col = data.split(";");
var img = image;

        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;
        }

        // How to put the image in an HTML element?
        $("img").src(the_image_taken_by_the_web_cam);
    },
    onCapture: function() {},
    debug: function() {},
    onLoad: function() {}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions