1

As a security guard we have to look an eye on a 60 inches TV which provides 20 camera output on it. So its really hard to watch the pot always. I decide to develope a programm to rectanglar the movement object in screen and make some beeps. My first step is to capture the screen frames. With below code its possible.

import numpy as np
import cv2
from mss import mss
from PIL import Image

bounding_box = {'top': 100, 'left': 0, 'width': 400, 'height': 300}

sct = mss()

while True:
    sct_img = sct.grab(bounding_box)
    cv2.imshow('screen', np.array(sct_img))

    if (cv2.waitKey(1) & 0xFF) == ord('q'):
        cv2.destroyAllWindows()
        break

As i understand we can use opencv to do some magic. There are some nice tutorial on net like this one. My problem is they got frames or stream from cams or ofline video files but here i have screen recording. Can you guys help me how to forward these frames into motion detection algorithm? Thanks

2
  • 1
    that blog post is using an API I've never seen. it's probably VERY outdated. Commented Jan 21, 2022 at 10:46
  • 1
    @ChristophRackwitz Yeah, looks like the last version of OpenCV that API was in is 2.2 , released in 2010. The github repo of that "nice tutorial" is from 2012 and was barely touched since. Commented Jan 21, 2022 at 13:21

1 Answer 1

1

The process is the same, you have to modify the image source.
In the example you linked - in the 'The smart way' code - replace

cv.QueryFrame(self.capture)
with
sct.grab(bounding_box)

to use the screengrab as image source

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks but as I understand it just get one image from screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.