feat: split camera worker and tick worker
This commit is contained in:
28
cameraworker.py
Normal file
28
cameraworker.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import sched
|
||||
|
||||
from redis import Redis
|
||||
|
||||
from control.camera import Camera
|
||||
|
||||
INTERVAL_TICK = 0.0125 # 20/s
|
||||
INTERVAL_IMAGE = 0.05 # 20/s
|
||||
|
||||
|
||||
scheduler = sched.scheduler()
|
||||
camera = Camera()
|
||||
|
||||
|
||||
def camera_image():
|
||||
scheduler.enter(INTERVAL_IMAGE, 1, camera_image)
|
||||
image = camera.get_image()
|
||||
redisdb.publish('image', image)
|
||||
|
||||
|
||||
scheduler.enter(INTERVAL_IMAGE, 1, camera_image)
|
||||
|
||||
if __name__ == '__main__':
|
||||
redisdb = Redis()
|
||||
try:
|
||||
scheduler.run()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
Reference in New Issue
Block a user