diff options
Diffstat (limited to 'camera.py')
-rwxr-xr-x[-rw-r--r--] | camera.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/camera.py b/camera.py index 18203c0..59c47eb 100644..100755 --- a/camera.py +++ b/camera.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import numpy as np from itertools import product, count from threading import Thread, Lock @@ -71,12 +72,16 @@ def get_rays(position, size = (800, 600), film_size = (0.035, 0.024), focal_leng return grid, focal_point-grid class Camera(Thread): - def __init__(self, geometry, module, context, lock, size=(800,600)): + def __init__(self, geometry, module, context, lock=None, size=(800,600)): Thread.__init__(self) self.geometry = geometry self.module = module self.context = context - self.lock = lock + + if lock is None: + self.lock = Lock() + else: + self.lock = lock self.size = size self.width, self.height = size @@ -247,7 +252,7 @@ class Camera(Thread): def update(self): if self.render: - while self.nlookup_calls < 10: + while self.nlookup_calls < 100: self.update_xyz_lookup(self.source_position) self.update_image() self.process_image() @@ -355,7 +360,7 @@ class Camera(Thread): self.source_position = self.point if event.key == K_p: - for i in range(10): + for i in range(100): self.update_xyz_lookup(self.point) self.source_position = self.point @@ -479,18 +484,14 @@ if __name__ == '__main__': raise Exception("can't find object %s" % args[0]) from pycuda.tools import make_default_context + from gpu import * - cuda.init() - context = make_default_context() - print 'device %s' % context.get_device().name() - - module = SourceModule(src.kernel, options=['-I' + src.dir], no_extern_c=True, cache_dir=False) geometry = build(obj, options.bits) - geometry.load(module) lock = Lock() - camera = Camera(geometry, module, context, lock, size) - - context.pop() + gpu = GPU() + gpu.load_geometry(geometry) + gpu.context.pop() + camera = Camera(geometry, gpu.module, gpu.context, lock, size=size) camera.start() |