OpenCV capturing desktop screen 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.
If you're targeting Windows OS, the option recommended by Engine seems ideal.
For Linux I ended up using an RTSP server(FFSERVER) as a VideoCapture input, then screencasting using FFMPEG with "x11grab".
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'));
and
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);
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...
链接地址: http://www.djcxy.com/p/81078.html上一篇: 从几个选项捕捉网络摄像头的解决方案
下一篇: OpenCV直播捕捉桌面屏幕