javascript - Display frames generated from opencv Django React
问题描述
I want to show a video generated from opencv, I am getting each frame from opencv and with the help of the django I send this to react.
So what happens, I send a request from react to django api to get frame from opencv and I then show that on react, I am calling this api in a loop to get multiple frames in a second and show on react ( its so fast that it shows frame in a form of video).
But I found that its a wrong way I have to use sockets to send so much request at a time.
Can some show me how can I get the same functionality through websockets,I have a short time so I need a smaller and quicker solution I have googled a lot but did't find nothing.
here's my current approach of sending multiples request:
const interval = setInterval(() => {
axios
.get("http://127.0.0.1:8000/MyApp/get_logs/")
.then(res => {
set_show(res.data);
})
.catch(err => {
console.log(err);
});
}, 500);
return () => clearInterval(interval);
The above function is called after every 0.5 seconds, I get a frame in base64 and show it in image, and it happens repeatedely that makes it in a video form, how can I achieve this through sockets using django and react.
解决方案
推荐阅读
- android - 如何停止从推送通知打开android应用程序
- javascript - 从 HTML 创建对象数组无法正常工作
- javascript - 无法在本地主机中显示数据库中的用户
- javascript - 无法访问不断变化的变量(Johnny-Five 操纵杆)
- asp.net-mvc - asp .net mvc postdata 在控制器中始终为 0
- java - Spring Boot (STS) 中无法识别 ConstraintCollectors
- database - 谁应该更新 EF Core 中的并发令牌?
- ffmpeg - 使用 ffmpeg 剪切视频时出现空流
- django - 如何在 Graphene Django 中记录有关 GraphQL 请求的信息?
- javascript - 使用循环突出显示表中的当前半小时