简体   繁体   中英

Sending webcam.js data to python server

I am working on a face detection project that will open client webcam and detect faces in the frame. For the detection part I am using opencv with python. For opening the webcam in the client system I am using webcam.js.

How do I send this data to the python server? Before using webcam.js I tried webRTC written in javascript. But I was facing the same problem of sending the data over to python for the face detection part.

I want to do the face detection in python because I plan on adding more functionality to the application and it will be easier to code this with python.

This is my code so far

<!DOCTYPE html>
<html lang="en" dir="ltr">

  <head>
    <meta charset="utf-8">
    <title></title>
  </head>

  <body>
    <!-- <h3>THIS IS THE HOMEPAGE OF FASHIONCAST</h3> -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/webcamjs/1.0.25/webcam.js"></script>
    <div id="my_camera" style="width:320px; height:240px;"></div>
    <script language="JavaScript">
      Webcam.attach('#my_camera');
    </script>
  </body>

</html>

Can I use websockets to send this data to python. If webcam.js is not the right way to accomplish this, how to solve my problem with webrtc. I could not find any links that talks about sending data from javascript to python.

One way to solve this problem with webrtc is to use RTCP to form a connection between the client and the server (the server behaves as the other peer). But i could find any resources to write the server part with python. aiortc does not support windows 10 platform and I am stuck here.

Thanks in advance

The easiest way to accomplish this is to draw the video to a canvas and then send the data over websockets. https://webrtchacks.com/webrtc-cv-tensorflow/ shows a complete example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM