class stream: def __init__(self): self.camera = CameraCapture("/dev/video0", (320,240), 8) def GET(self): i = web.input(stat=None) print 'GET = ' + str(i.stat) session.camera_stat = True if i.stat == 'open' else False web.header('Access-Control-Allow-Origin', '*') web.header('Content-Type', 'multipart/x-mixed-replace;boundary=pi.webcam') frame_id = self.camera.frame_count #while session.camera_stat: while True: self.camera.frame_available.acquire() while frame_id == self.camera.frame_count: self.camera.frame_available.wait() self.camera.frame_available.release() frame_id = self.camera.frame_count response = "Content-type: image/jpeg\n\n" response = response + self.camera.get_image() response = response + "\n--pi.webcam\n" yield response
def __init__(self): self.camera = CameraCapture("/dev/video0", (320,240), 8)