-1

How can I capture camera feeds from browser and send to flask server app and stop capturing when user clicks stop ?

The feed will be processed by the server but what I want is to get the camera feeds to my flask app the rest I can implement.

<div id="container">
    <video autoplay="true" id="videoElement">

    </video>
</div>
<script type="text/javascript" charset="utf-8">

var video = document.querySelector("#videoElement");




if (navigator.mediaDevices.getUserMedia) {
  navigator.mediaDevices.getUserMedia({ video: true })
    .then(function (stream) {

      /bI want to send these frame to server

      //video_t.srcObject = stream

      
    });
}

// returns a frame encoded in base64
const getFrame = () => {
    const canvas = document.createElement('canvas');
    canvas.width = video_t.videoWidth;
    canvas.height = video_t.videoHeight;
    canvas.getContext('2d').drawImage(video_t, 0, 0);
    const data = canvas.toDataURL('image/png');
    return data;
}




</script>

1 Answers1

0

I have found a way to implement what I was looking for, something similar here

How to stream live video frames from client to flask server and back to the client?