forked from jmercier/PyDC1394
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
59 lines (47 loc) · 1.1 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pygame
pygame.init()
import video1394
import numpy as np
import scipy as sc
import traceback
from pylab import *
import time
import sys
size = width, height = 480, 640
screen = pygame.display.set_mode(size)
i = 0
def test(im, timestamp):
global i
sys.stderr.write("grab %d %d \r" % (i, timestamp))
i += 1
try:
py_img = pygame.image.frombuffer(im.T.copy(), im.shape, "RGB")
screen.blit(py_img, py_img.get_rect())
pygame.display.flip()
except (Exception, e):
print e
ctx = video1394.DC1394Context()
camera = ctx.createCamera(0)
camera.resetBus()
camera.mode = video1394.VIDEO_MODE_640x480_RGB8
camera.framerate = video1394.FRAMERATE_15
camera.print_info()
camera.grabEvent.addObserver(test)
print camera.node
print camera.cycleTimer
print camera.broadcast
print camera.oneshot
print camera.multishot
camera.sharpness = 0
print camera.sharpness
camera.start()
import gobject
import signal
gobject.threads_init()
loop = gobject.MainLoop()
def onstop(*args):
loop.quit()
signal.signal(signal.SIGINT, onstop)
loop.run()
print "Stopping Camera"
camera.stop()