OpenCV捕获桌面屏幕直播 [英] OpenCV capturing desktop screen live

查看:1877
本文介绍了OpenCV捕获桌面屏幕直播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OpenCV作为一个c ++编码项目。我有一些困难,在OpenCV的一些限制,我想分析视频文件和检测某些对象。这工作完美,但现在我想要它分析我的桌面屏幕的一部分。 (live)

I'm using OpenCV for a c++ coding project. I'm having some difficulty with some of the limitations in OpenCV, I want to analyse a video file and detect certain objects. This works perfectly, but now I want it to analyse a section of my desktop screen. (live)

有人有一个线索如何完成这个?我想到制作一个捕获我的桌面屏幕的网络摄像机模拟器,但我认为这是复杂的,它应该更容易。

Does anybody have a clue how to accomplish this? I thought of making a webcam simulator that captures my desktop screen but I think thats way to complicated and it should be much more easy.

推荐答案

p>如果您的目标是Windows操作系统,Engine推荐的选项似乎是理想的。

If you're targeting Windows OS, the option recommended by Engine seems ideal.

对于Linux,我最终使用RTSP服务器(FFSERVER)作为VideoCapture输入,然后使用FFMPEG和x11grab进行屏幕录制。

For Linux I ended up using an RTSP server(FFSERVER) as a VideoCapture input, then screencasting using FFMPEG with "x11grab".

FFMPEG for Windows将接受screen-capture-recorder应用程序作为输入,但我没有在Windows上设置RTSP服务器的经验。

FFMPEG for Windows will accept the "screen-capture-recorder" application as an input, but I don't have any experience setting up an RTSP server on windows.

对于我的设置,翻译为如下代码:

For my setup this translated to code that looked like this:

cv::VideoCapture cap;
cap.open("http://localhost:8090/live.flv"); // open the default camera
cap.set(CV_CAP_PROP_FOURCC, CV_FOURCC('F', 'L', 'V', '1'));

cv::resize(frame, frame, cv::Size(200, 200));
cv::VideoWriter outStream("http://localhost:8090/feed2.ffm",
CV_FOURCC('F', 'L', 'V', '1'), 10, cv::Size(200, 200), true);

200x200分辨率对于尽量减少延迟是必要的,所以如果你可以直接抓住屏幕缓冲区, /编码,从性能的角度看更好的...

The 200x200 resolution was necessary to minimize latency so if you can grab the screen buffer directly to avoid unnecessary screencasting/encoding that sounds better from a performance standpoint...

这篇关于OpenCV捕获桌面屏幕直播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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