【发布时间】:2021-09-07 04:24:26
【问题描述】:
我创建了第一个显示客户端网络摄像头帧的网络应用程序(python 和 django)
这是我的 video.js
'use strict';
// On this codelab, you will be streaming only video (video: true).
const mediaStreamConstraints = {
video: true,
};
// Video element where stream will be placed.
const localVideo = document.querySelector('video');
// Local stream that will be reproduced on the video.
let localStream;
// Handles success by adding the MediaStream to the video element.
function gotLocalMediaStream(mediaStream) {
localStream = mediaStream;
localVideo.srcObject = mediaStream;
}
// Handles error by logging a message to the console with the error message.
function handleLocalMediaStreamError(error) {
console.log('navigator.getUserMedia error: ', error);
}
// Initializes media stream.
navigator.mediaDevices.getUserMedia(mediaStreamConstraints)
.then(gotLocalMediaStream).catch(handleLocalMediaStreamError);
但是,我想使用客户端的网络摄像头框架作为我的机器学习脚本 (python .py) 文件的输入。
在本地,可以通过 opencv 和 numpy 轻松完成。
但在网络中,我无法将帧提供给 ML 模型。
有什么建议吗?
【问题讨论】:
-
您可以将
localStream存储到本地视频文件中,并使用python将其传输到机器上。或者创建python webrtc客户端github.com/aiortc/aiortc
标签: javascript python django webrtc