4

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.

RTNTVG
  • 53
  • 1
  • 2
  • 7
  • http://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat – Engine Nov 12 '14 at 15:29
  • Thanks for your answer! I'm looking more for something like this http://www.youtube.com/watch?v=z7rS6bH_OHY – RTNTVG Nov 12 '14 at 16:03
  • The link "engine" gave you is what you need (windows OS). You could limit the capturing to a subarea of the full screen later or you could capture a single window if you want to. – Micka Nov 12 '14 at 20:40
  • libvlc could be a choice too: http://stackoverflow.com/questions/16186401/libvlc-stream-part-of-screen – seleciii44 Dec 25 '15 at 22:36

1 Answers1

4

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...

A. Breuer
  • 71
  • 6