Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 27d4cd8

Browse files
Add files via upload
1 parent 55a3820 commit 27d4cd8

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import multiprocessing
2+
import time
3+
import cv2
4+
import mss
5+
import numpy
6+
7+
title = "FPS benchmark"
8+
start_time = time.time()
9+
display_time = 2 # displays the frame rate every 2 second
10+
fps = 0
11+
sct = mss.mss()
12+
# Set monitor size to capture
13+
monitor = {"top": 40, "left": 0, "width": 800, "height": 640}
14+
15+
16+
def GRABMSS_screeb(q):
17+
while True:
18+
# Get raw pixels from the screen, save it to a Numpy array
19+
img = numpy.array(sct.grab(monitor))
20+
# To get real color we do this:
21+
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
22+
q.put_nowait(img)
23+
q.join()
24+
25+
def SHOWMSS_screeb(q):
26+
global fps, start_time
27+
while True:
28+
if not q.empty():
29+
img = q.get_nowait()
30+
q.task_done()
31+
# To get real color we do this:
32+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
33+
# Display the picture
34+
cv2.imshow(title, cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
35+
# Display the picture in grayscale
36+
fps+=1
37+
TIME = time.time() - start_time
38+
if (TIME) >= display_time :
39+
print("FPS: ", fps / (TIME))
40+
fps = 0
41+
start_time = time.time()
42+
# Press "q" to quit
43+
if cv2.waitKey(25) & 0xFF == ord("q"):
44+
cv2.destroyAllWindows()
45+
break
46+
47+
if __name__=="__main__":
48+
# Queue
49+
q = multiprocessing.JoinableQueue()
50+
51+
# creating new processes
52+
p1 = multiprocessing.Process(target=GRABMSS_screeb, args=(q, ))
53+
p2 = multiprocessing.Process(target=SHOWMSS_screeb, args=(q, ))
54+
55+
# starting our processes
56+
p1.start()
57+
p2.start()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
##Upload soon

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /