def _thread(cls):
# frame grabber loop
while cfg.camera_active:
sbuffer = StringIO.StringIO()
camtest = False
while camtest == False:
camtest, rawimg = cfg.camera.read()
if cfg.cv_hflip:
rawimg = cv2.flip(rawimg, 1)
if cfg.cv_vflip:
rawimg = cv2.flip(rawimg, 0)
imgRGB=cv2.cvtColor(rawimg, cv2.COLOR_BGR2RGB)
img = Image.fromarray(imgRGB)
img.save(sbuffer, 'JPEG')
cls.frame = sbuffer.getvalue()
# if there hasn't been any clients asking for frames in
# the last 10 seconds stop the thread
if time.time() - cls.last_access > 10:
break
评论列表
文章目录