doc: Fix typos in GP_TempAlloc() documentation.
[gfxprim/pasky.git] / demos / py_simple / cam_view.py
blob6692abb914bb83bd6ad9c2ae1382042bfb7142d6
1 #!/usr/bin/env python
3 from sys import exit
4 from time import sleep
6 import gfxprim.core as core
7 import gfxprim.backends as backends
8 import gfxprim.input as input
9 import gfxprim.grabbers as grabbers
11 def main():
12 # Open grabber (i.e. web camera)
13 grabber = grabbers.GrabberV4L2Init("/dev/video0", 320, 240);
14 assert(grabber)
16 # Create X11 window
17 bk = backends.BackendX11Init(None, 0, 0, grabber.frame.w, grabber.frame.h, "Grabbers test", 0)
18 assert(bk)
20 # Start grabber capture
21 grabber.Start();
23 # Event loop
24 while True:
25 sleep(0.01)
27 if (grabber.Poll()):
28 grabber.frame.Blit(0, 0, bk.context, 0, 0, grabber.frame.w, grabber.frame.h)
29 bk.Flip()
31 ev = bk.PollEvent()
33 if (ev is None):
34 continue
36 input.EventDump(ev)
38 if (ev.type == input.EV_KEY):
39 exit(0)
40 elif (ev.type == input.EV_SYS):
41 if (ev.code == input.EV_SYS_QUIT):
42 exit(0)
44 if __name__ == '__main__':
45 main()