Webcam over localhost to another machine

Dear Sir,
After much troubleshooting, I have been able to work the webcam fine for now but when i connect the localhost using the machine’s IP from another PC it say’s webcam.js error? kindly help me solve this issue. Thank you. Below is my code.

  <div class="col-75">   
     <div id="my_camera"></div><br>
            <input type=button value="Take Snapshot" onClick="take_snapshot()" name="image">
            <input type="hidden" name="image" class="image-tag">
                
            
            <div class="col-md-6">
            <div id="results">Your captured image will appear here...

            </div>
            
         </div></div>    
      <div class="row">
           
      <input type="submit" value="Submit" class="btn btn-success" name="ronel">
      </div>
          
  </form>
</div>
</body>
</html>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/webcamjs/1.0.25/webcam.min.js"></script>
   
 <!-- Configure a few settings and attach camera -->
<script language="JavaScript">
    Webcam.set({
        width: 140,
        height: 150,
        image_format: 'jpeg',
        jpeg_quality: 90
    });
  
    Webcam.attach( '#my_camera' );
  
    function take_snapshot() {
        Webcam.snap( function(data_uri) {
            $(".image-tag").val(data_uri);
            document.getElementById('results').innerHTML = '<img src="'+data_uri+'"/>';
        } );
    }
</script>

Javascript on Machine X cannot access the webcam on Machine Y.

The sheer amount of security violation you’re looking at there…

No. They’re using WebcamJS and it’s pretty legal. It sounds like they’re using machine 1 for hosting it locally and machine 2 as the main testing machine. This is completely legal. My PHP professor did the same thing because he went cheap mode on us so he didn’t get any hosting services for us. Instead, he had us setup 2 VMs, 1 for hosting the environment locally and the other for writing code and testing it by syncing it to the other machine.

Anything that gets described as “pretty legal” is well worth running the other direction from.

Javascript cannot access the webcam on another computer.

If computer X is hosting images from a webcam, then computer Y isn’t accessing the webcam on another computer, it’s accessing the hosted images/feed, which is an entirely different scenario.

WebcamJS, so far as i can see, does not host the resulting images; it accesses the LOCAL webcam, and sticks the LOCAL webcam’s image into an html element in the browser LOCALLY.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.