0

I am currently using webcam-easy.js to stream my PC's webcam to a Flask Server and display that stream.

What I would like to do is take that video feed and stream it to another server running OpenCV.

Here is my app.py:

from flask import Flask, render_template, send_from_directory, Response

app = Flask(__name__)


@app.route('/')
def hello_world():
    return render_template('index.html')

if __name__ == '__main__':
    app.run()

And this is my index.html, where I am getting the video stream:

<script type="text/javascript" src="https://unpkg.com/webcam-easy/dist/webcam-easy.min.js"></script>
<video id="webcam" autoplay playsinline width="640" height="480"></video>
<canvas id="canvas" class="d-none"></canvas>
<audio id="snapSound" src="audio/snap.wav" preload = "auto"></audio>
<script>
    const webcamElement = document.getElementById('webcam');
    const canvasElement = document.getElementById('canvas');
    const snapSoundElement = document.getElementById('snapSound');
    const webcam = new Webcam(webcamElement, 'user', canvasElement, snapSoundElement);

    webcam.start()
   .then(result =>{
      console.log("webcam started");
   })
   .catch(err => {
       console.log(err);
   });

</script>

So, how would I go on about streaming that webcam feed to another OpenCV Server?

Noootron27
  • 65
  • 1
  • 1
  • 6
  • 1
    You may look at [aiortc](https://github.com/jlaine/aiortc/blob/master/examples/server/client.js) from [this](https://stackoverflow.com/questions/53187474/receive-webrtc-video-stream-using-python-opencv-in-real-time) answer. Another approach is taking images from the camera, add them to a buffer and send post requests to your server. See [Brain-Power-Amazon-Fidgetology](https://github.com/brain-power/Brain-Power-Amazon-Fidgetology/blob/master/dashboard/js/app/webcam-stream-controller.js) is – bartolo-otrit Oct 23 '20 at 10:17
  • Thanks for commenting...Sadly I believe, that it is not possible to implement aiortc when using Flask, or Django for that matter. – Noootron27 Oct 24 '20 at 14:23

0 Answers0