Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:12:40+00:00 2026-06-17T10:12:40+00:00

I am using jquery webcam plugin and when i take the picture its not

  • 0

I am using jquery webcam plugin and when i take the picture its not showing up in the canvas. I would like to know if i have to upload the image to the server first before it can be displayed on the canvas or will it be shown once its snapped.

Code:

    $(document).ready(function(){


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


                onLoad: function() {

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

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

                onCapture: function () {

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

                    webcam.snap();

                    });

                    webcam.snap();
                },

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





        }); 
});

    <label id="status"></label>                             
                        <div id="camera"></div>
                        <div><p><canvas id="canvas" height="240" width="320"></canvas></p></div>
                         <a href="javascript:webcam.capture();changeFilter();void(0);">Take a picture instantly</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:12:42+00:00Added an answer on June 17, 2026 at 10:12 am

    This is what i did and it works very well now. Now it just to figure how to upload to the server in java:

    Code

    <script type="text/javascript">
    
        var pos = 0, ctx = null, saveCB, image = [];
        var canvas = document.createElement('canvas');
        canvas.setAttribute('width', 320);
        canvas.setAttribute('height', 240);
        ctx = canvas.getContext('2d');
        image = ctx.getImageData(0, 0, 320, 240);
    
        var saveCB = 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);
                foto = canvas.toDataURL("image/png");
                pos = 0;
            }
        };
    
    
        $(document).ready(function(){
    
    
            $("#camera").webcam({
                    width: 315,
                    height: 240,
                    useMicrophone: false,
                    mode: "callback",
                    swffile: "resources/swf/jscam_canvas_only.swf",
                    quality:85,
    
                    onSave: saveCB,
                    onCapture: function () {
                        webcam.save();
                    }
    
    
    
            }); 
    
    
    
            $('#upload').click(function () {
                webcam.capture();
                return false;
            });
    
    
            window.addEventListener("load", function() {
                var canvas = document.getElementById("canvas");
    
                if (canvas.getContext) {
                    ctx = document.getElementById("canvas").getContext("2d");
                    ctx.clearRect(0, 0, 320, 240);
    
    
                    image = ctx.getImageData(0, 0, 320, 240);
                }
    
                }, false);
    
    });
    
        <label id="status"></label>                             
                            <div id="camera"></div>
                            <div><p><canvas id="canvas" height="240" width="320"></canvas></p></div>
                            <input  id="upload" type="button" value="Take Photo">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery UI I have two radio buttons, Approve/Reject, which I would like to
Using jQuery Nearest Element , I would like to select elements in a circular
I'm using jQuery Webcam Plugin, when I try to append the , when my
Using jQuery, I need to select all elements that do not have a background
Using JQuery animate I would like to operate with css classes, defined somewhere in
I'm using this jQuery webcam plugin in a website I'm working on. If you
Using jQuery and backbone.js, I would like to separate the JavaScript from the HTML
I am using the jQuery Webcam Plugin with this code: $(#camera).webcam({ width: 250, height:
I am using the jquery webcam plugin with the flash save method. I want
I'm using this jQuery plugin: http://www.xarg.org/project/jquery-webcam-plugin/ When I run this code on localhost ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.