-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
57 lines (40 loc) · 1.05 KB
/
example.py
File metadata and controls
57 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import display as dsp
import time
import numpy as np
import random
global display
def _parse_img(num):
if num % 5 == 0:
# use global display
global display
# random img
img = np.ones((256,256,1), np.uint8)
for row in range(img.shape[0]):
for col in range(img.shape[1]):
img[row,col,0] = random.randint(0, 255)
# put img on display queue to show it
display.show(img)
else:
pass
# function which processes every image before show it at display
# function take img1 argument and return img2
def img_processing(img1):
# DO STH WITH IMG
print('processing1')
img2 = img1
print('processing2')
return img2
if __name__ == '__main__':
global display
display = dsp.DisplayManager(name='Dispaly Example', # disply name
interval=0.5, # sleep time [s]
size=30, # queue size
on_update=img_processing) # function called to process img before show it on screen
# sth like main
for i in range(100):
print('for ', i)
time.sleep(0.1)
if i % 5 == 0:
_parse_img(i)
# finish thread
display.finish()