1

Have been getting this error since the first time I tried to use the jQuery WebCam... I googled for like 18Hours, trying all possible Examples ever available, NONE works whenever I just Call the capture method of the webcam.

Please Note:: This might sound duplicate but, I spent hours and hours in stackOverflow, all examples gave not good result. the closest, infact the code am using is from; jquery webcam plugin TypeError: webcam.capture is not a function thrown occasionally and jquery webcam plugin TypeError: webcam.capture is not a function thrown occasionally and Jquery Webcam on webpage help needed and jQuery webcam plugin - saving image and Display pic in web page captured from webcam and MANY MORE.....

I tried the suggestions by the accpted answer, still yielded no progress...

 <html>
  <head>
     <script type="text/javascript" src="jQ.js"></script>
   <script type="text/javascript" src="cam/jquery.webcam.js"></script>
 </head>
  <body>


<script type="text/javascript">
   $(document).ready(function(){


    $("#camera").webcam({
            width: 315,
            height: 240,
            useMicrophone: false,
            mode: "callback",
            swffile: "cam/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.capture();
                 alert($.webcam.getFrameAsBase64());    
                });


            },

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





    }); });
</script>


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

</body>
</html>

Does anyone know any possible reason why it cannot work or what am i doing wrong, please I will be glad to be lectured on this. thx

Community
  • 1
  • 1
Universal Grasp
  • 1,835
  • 3
  • 20
  • 29

1 Answers1

0

You are loading the scripts in the wrong order! first u loads the library and then you load the script that has its code to be opening the camera! getting that order below ..

<script type="text/javascript" src="cam/jquery.webcam.js"></script>
<script type="text/javascript" src="jQ.js"></script>