如何将openCV视频流式传输到HTML网页? [英] How do I stream an openCV video to an HTML webpage?

查看:1383
本文介绍了如何将openCV视频流式传输到HTML网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个机器人,其上将有一个网络摄像头,以提供一些简单的对象检测。现在,我想简单地将视频流式传输到机器人上托管的网页,并且能够从其他设备查看。我已经写了一个简单的测试脚本在Python(我最终会移动到C + +,我选择的语言),可以从我的网络摄像头,然后做任何我需要的从那里。问题是,我不能在应用程序运行时将视频写入文件,它只会在我退出脚本后写入文件。我已经有一个web服务器运行,我可以编写HTML的基本代码,以托管文件中的视频,以及所有这些都工作。

I am making a robot that will have a webcam on it to provide some simple object detection. For right now, I would like to simply stream the video to a webpage hosted on the robot and be able to view it from another device. I have written a simple test script in Python ( I will eventually move to C++, my language of choice) which can get a stream from my webcam, and then do whatever I need with it from there. The problem then, is that I can't write the video to a file while the app is running, it only writes the file after I quit the script. I already have a webserver running, and I can write the basic code in HTML to host a video from a file as well, and all of that works.

总结:
openCV2在Python和/或C ++能够直播视频只使用openCV?
如果没有,你会建议什么库,我尝试采取CV捕获对象或Mat对象,并将其写入流,然后我可以放在网页上?
在HTML中,标签是流媒体视频的好主意吗?

To summarize: Is openCV2 in Python and/or C++ capable of livestreaming video using only openCV? If not, what library would you recommend that I try to take a CV capture object or Mat object and write it to a stream that I can then put on a webpage? In HTML, is the tag a good idea to stream video with?

非常感谢您的建议,我可以使用所有的指针* get!

Thank you very much for the advice, I can use all the pointers* I can get!

如果你需要澄清/代码发布/解释比我提供的更多,请问,我会这样做!

If you need something clarified/code posted/explanations further than what I have given, please ask and I will do so!

推荐答案

下面的线程解决了OpenCV和Python中的流帧问题:
将原始OpenCV图像导入FFmpeg

The issue of streaming frames out of OpenCV and Python has been addressed in the following thread: Pipe raw OpenCV images to FFmpeg

我,但他们声称它为他们。

This didn't work for me, but they claim it did for them.

它在我的情况下不工作的原因似乎是,对于一些输出帧额外的字节添加或丢失,在输出到stdout在capture.py之间,输入到FFMPEG。因此,字节数不对应于帧数。我不知道为什么会是这样。我使用Windows 7。

The reason for it not working in my case seems to be that for some output frames additional bytes were added or lost, somewhere between the output to stdout in capture.py and the input to FFMPEG. Therefore, the number of bytes doesn't correspond to the number of frames. I am not sure why this is the case. I used Windows 7.

如果你尝试这个,我很想知道你的经验。我也试过一个修改版本的capture.py使用cv2,并失败了相同的原因。

I will be curious to hear what is your experience if you try this. I also tried a modified version of capture.py using cv2, and failed for the same reasons.

这篇关于如何将openCV视频流式传输到HTML网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆