Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I have a server connected to a GoPro camera, which sends the images in base64 format, and can be seen on localhost, now I need to capture screenshot, but I can not, any ideas?

HTML
<html>
  <head>
    <title>Go Pro cliente</title>
    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" charset="utf-8">
    var flag = false;
    var imgArray = new Array();


      $(document).ready(function(){
         if ("WebSocket" in window) {
            var ws_path = 'ws://' + window.location.host + window.location.pathname + 'ws';
            //alert(ws_path);
            var ws = new WebSocket (ws_path);
            //alert(ws);
            ws.onopen = function () {
               ws.send(1);
            };
            ws.onmessage = function (msg) 
            {
               $("#cam").attr('src', 'data:image/jpg;base64,' + msg.data);
                   if ( flag == true) 
                    {
                        $("#img").attr('src', 'data:image/jpg;base64,' + msg.data);
                        flag = false; 
                        var url = img.src.replace('data:image/jpg;base64,' + msg.data);
                    }
               ws.send(1);
            };
            ws.onerror = function (e) {
               console.log(e);
               ws.send(1);
            };
         } else {
             alert("WebSocket no soportado");
         }
      });

      function capture() 
      {
            flag = true;
      };



    </script>
  </head>
  <body>

  <div id="video"><center>
      <H1>Video caputado desde Go Pro</H1>
        <img id="cam" src=""/><br>
     <button id="capture" onclick="capture();" type="button">Screen Shot</button> 
  </div>

  <div id="screenshot">
      <h2><center>Capturas tomadas</h2>
      <img id="url" src="" /><br>
  </div>

   <a id="acapture" href="" download="" style="display : none"></a>     


  </body>
</html> 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900