def run(self):
bytes = b''
while not self.thread_cancelled:
try:
bytes += self.stream.raw.read(1024)
a = bytes.find(b'\xff\xd8')
b = bytes.find(b'\xff\xd9')
if a != -1 and b != -1:
jpg = bytes[a:b + 2]
bytes = bytes[b + 2:]
frame = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.IMREAD_COLOR)
#------------------ insert algorythms HERE ------------------
# Display the resulting frame
cv2.imshow('Video', frame)
# ------------------ algorythms end HERE ------------------
if cv2.waitKey(1) & 0xFF == ord('q'):
exit(0)
except ThreadError:
self.thread_cancelled = True
评论列表
文章目录