aboutsummaryrefslogtreecommitdiff
path: root/inputs
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-17 02:45:27 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-17 02:45:27 -0500
commit67c62d8c9e650f594e9aea348b8ed0c1351c7d81 (patch)
treee71d7ac7fc2538eda3e43e8e591342cab9620d06 /inputs
parent2df9e408a0ff74539862c4a4e562a878cc11a329 (diff)
Added JPGInput to process images. Modified Input and LightInstallation to support passing multiple
inputs simultaeneously. Added FadeIn Pixel event. Needs work / configurability.
Diffstat (limited to 'inputs')
-rw-r--r--inputs/JPGInput.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/inputs/JPGInput.py b/inputs/JPGInput.py
new file mode 100644
index 0000000..fd58a47
--- /dev/null
+++ b/inputs/JPGInput.py
@@ -0,0 +1,33 @@
+from operationscore.Input import *
+from PIL import Image
+import util.ComponentRegistry as compReg
+import os
+class JPGInput(Input):
+ def inputInit(self):
+ self.images = []
+ self.imageIndex = 0
+ compReg.getLock().acquire()
+ minX,minY,maxX,maxY = compReg.getComponent('Screen').getSize()
+ compReg.getLock().release()
+ sWidth = maxX-minX
+ sHeight = maxY-minY
+ for filename in os.listdir(self['Directory']):
+ path = os.path.join(self['Directory'], filename)
+ if '.jpg' in path or '.bmp' in path:
+ im = Image.open(path) #file to open
+ (w,h)=im.size
+ print w,h
+ xScale = sWidth/float(w)
+ yScale = sHeight/float(h)
+ pixels = []
+ for x in range(w):
+ for y in range(h):
+ rgb = im.getpixel((x,y))
+ pixels.append({'Location':(x*xScale+minX,minY+y*yScale),'Color':rgb})
+
+ self.images.append(pixels)
+
+ def sensingLoop(self):
+ self.imageIndex += 1
+ self.imageIndex = self.imageIndex % len(self.images)
+ self.respond(self.images[self.imageIndex])