SerpentAI / D3DShot

Extremely fast and robust screen capture on Windows with the Desktop Duplication API
MIT License
323 stars 73 forks source link

1,000,000+ fps in screen capture #39

Closed Pro100rus32 closed 2 years ago

Pro100rus32 commented 3 years ago

How can I start capturing on the same thread as my code? Because getting the last frame is not an option, since I cannot find out when it changed.

example:

import d3dshot
from time import sleep, time
d = d3dshot.create(capture_output="numpy", frame_buffer_size=90)
d.capture(region=(653, 354, 713, 404))
sleep(1)
fps = 0
display_time = 1
start_time = 0
while True:
    test = d.get_latest_frame()
    fps+=1
    TIME = time() - start_time
    if (TIME) >= display_time :
        print("FPS: ", int(fps / (TIME)))
        start_time = time()
        fps = 0

Output:

FPS:  1562927
FPS:  1544829
FPS:  1702034

wtf? 1000000 fps?

TheBlackPlague commented 2 years ago

@Pro100rus32 I think you're forgetting to set start_time to time.time().

Pro100rus32 commented 2 years ago

@Pro100rus32 I think you're forgetting to set start_time to time.time().

No, everything is correct here. I found the problem. The capture is running on a different thread.