-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.py
37 lines (30 loc) · 971 Bytes
/
camera.py
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
from twisted.internet import reactor, task, defer, threads
import cv2
import numpy as np
class CameraCtrl():
def __init__(self):
self.__cb_notify_item = None
#self.__stop_monitor = True
def init(self, cb_notify_item):
# initialization for camera and thread
self.__cb_notify_item = cb_notify_item
def start(self):
if self.__cb_notify_item is None:
print "please call init(cb_notify_item) with a callback as input at first"
else:
print "ok, let's start"
def stop(self):
print "let's stop"
def cb_notify_item(sku_id,num):
print "sku_id=%d, num=%d" % (sku_id, num)
def main():
cameraCtrl = CameraCtrl()
#threads.deferToThread(cameraCtrl.startMonitor())
cameraCtrl.init(cb_notify_item)
cameraCtrl.start()
#key = cv2.waitKey(1) & 0xFF
#if key == ord('q'):
# cameraCtrl.stopMonitor()
reactor.run()
if __name__ == "__main__":
main()