summaryrefslogtreecommitdiff
path: root/camera.py
diff options
context:
space:
mode:
Diffstat (limited to 'camera.py')
-rwxr-xr-xcamera.py41
1 files changed, 9 insertions, 32 deletions
diff --git a/camera.py b/camera.py
index f4439f5..2071d25 100755
--- a/camera.py
+++ b/camera.py
@@ -21,10 +21,6 @@ from subprocess import call
import shutil
import tempfile
-from histogram import *
-
-import matplotlib.pyplot as plt
-
def encode_movie(dir):
root, ext = 'movie', 'avi'
for i in count():
@@ -39,23 +35,11 @@ def encode_movie(dir):
print 'movie saved to %s.' % filename
-def get_rays(position, size = (800, 600), film_size = (0.035, 0.024), focal_length=0.05):
- """
- Generate ray positions and directions from a pinhole camera facing the negative y direction.
+def get_rays(position, size = (800, 600), width = 0.035, focal_length=0.05):
+ height = width*(size[1]/float(size[0]))
- Args:
- - position: tuple,
- Position of the camera.
- - size: tuple, *optional*
- Pixel array shape.
- - film_size: tuple, *optional*
- Physical size of photographic film. Defaults to 35mm film size.
- - focal_length: float, *optional*
- Focal length of camera.
- """
-
- x = np.linspace(-film_size[0]/2, film_size[0]/2, size[0])
- z = np.linspace(-film_size[1]/2, film_size[1]/2, size[1])
+ x = np.linspace(-width/2, width/2, size[0])
+ z = np.linspace(-height/2, height/2, size[1])
grid = np.array(tuple(product(x,[0],z)))
@@ -300,6 +284,9 @@ class Camera(Thread):
self.update_xyz_lookup(self.point)
self.source_position = self.point
+ elif event.key == K_F11:
+ pygame.display.toggle_fullscreen()
+
elif event.key == K_ESCAPE:
self.done = True
return
@@ -424,7 +411,7 @@ class EventViewer(Camera):
self.T = self.f.Get('T')
self.T.GetEntry(0)
- @timeit
+ #@timeit
def color_hit_pmts(self):
self.gpu.reset_colors()
@@ -437,15 +424,9 @@ class EventViewer(Camera):
t[i] = channel.t
q[i] = channel.q
- self.gpu.color_solids(solid_ids, map_to_color(t))
+ self.gpu.color_solids(solid_ids, map_to_color(t, (t.min(), t.mean())))
self.update()
- plt.clf()
- plt.hist(t*1e9, 100)
- plt.xlabel('Time (ns)')
- plt.ylabel('Entries')
- plt.draw()
-
def process_event(self, event):
if event.type == KEYDOWN:
if event.key == K_PAGEUP:
@@ -464,10 +445,6 @@ class EventViewer(Camera):
Camera.process_event(self, event)
- def run(self):
- plt.ion()
- Camera.run(self)
-
if __name__ == '__main__':
import optparse
import inspect