2

I am trying to capture the screen and show the images continuously using opencv-python. But for some reason the images are not stacking on top of each others like normally. Please look at the source code and the screenshot below. I am on ubuntu 18.04. Thanks!!

    import time
    import cv2
    import mss
    import numpy as np

    with mss.mss() as sct:
        # Part of the screen to capture
        monitor = {"top": 40, "left": 0, "width": 800, "height": 640}

        while True:
            last_time = time.time()

            # Get raw pixels from the screen, save it to a Numpy array
            img = np.array(sct.grab(monitor))

            # Display the picture
            cv2.imshow('frame', img)

            print("fps: {}".format(1 / (time.time() - last_time)))

            # Press "q" to quit
            if cv2.waitKey(1) & 0xFF == ord("q"):
                cv2.destroyAllWindows()
                break

HERE IS THE SCREENSHOT

Tiger-222
  • 6,677
  • 3
  • 47
  • 60
CoFlo
  • 21
  • 2
  • 1
    Move your opencv window out of the capture zone.. Or is it expected to also capture the opencv image recursively ? – Tezirg Dec 11 '18 at 14:55
  • 3
    What do you mean with stack normally? This looks like the expected behaviour... you capture a screenshot and display it... repeat it several times and you have the moved effect. Maybe you should do destroyAllWindows() before capturing if you want not to get OpenCV image in the screenshot. – api55 Dec 11 '18 at 14:58
  • 1
    oh haha i see....noob mistake.... I am new to this so... Thank you :D – CoFlo Dec 11 '18 at 15:10

0 Answers0