0

Step-by-step execution:

  1. Closing all active programs
  2. Capturing the Dota 2 for 5 seconds (Size Dota 2 window (16x9, 1176x664)
  3. Transition to pyarm and execution of the code

Code:

import time
import cv2
import mss
import numpy

def screen_record_efficiency():
    # game window
    mon = {"top": 0, "left": 0, "width": 800, "height": 600}

    title = "Dota [FPS]"
    fps = 0
    sct = mss.mss()
    last_time = time.time()

    while True:
         img = numpy.asarray(sct.grab(mon))
         fps += 1

         cv2.imshow(title, img)
         if cv2.waitKey(25) & 0xFF == ord("q"):
            cv2.destroyAllWindows()
            break
    return fps

screen_record_efficiency()

When the code is launched, does not give any errors, does not show the grabbed dota 2 window enter image description here

Tiger-222
  • 6,677
  • 3
  • 47
  • 60
  • You need to use the `&` operator, not the `and` operator. There's a huge difference. – Tim Roberts Dec 02 '22 at 00:30
  • i use it but not diference, same – Vova Snopyk Dec 02 '22 at 00:38
  • 1
    As is, you never call the function you defined, so all that script does is import a bunch of libraries. Both OpenCV and numpy are on the larger side, so if they're not cached, it takes a while to load them. Please, [edit] your question, and make sure you provide a [mcve] that actually does something other than imports. – Dan Mašek Dec 02 '22 at 00:50
  • You will have to add some debug prints line by line to figure out how far you are getting. Do you know exactly which version of OpenCV you installed? There's a version that supports displaying to the screen, and one that does not. – Tim Roberts Dec 02 '22 at 04:44
  • traceback is required. -- [tour], [ask], [mre] -- all that `& 0xFF` stuff on the waitKey() call is **obsolete and redundant**. never ever do that. – Christoph Rackwitz Dec 03 '22 at 23:35

0 Answers0