aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Bogart <bbogart@users.sourceforge.net>2007-03-14 05:58:15 +0000
committerB. Bogart <bbogart@users.sourceforge.net>2007-03-14 05:58:15 +0000
commitb06ead7b7042f3471d1fe7232ee34b44fc89c0b5 (patch)
treec054b68dce18479b6fe4438d32667ba34e6b99a6
parentd0194be0987648655b3fec769126ecf70e8de9ff (diff)
Added the python class to convert bytes to CVS since its currently a
dependancy. Need to change the name and include only ptz stuff in the script. svn path=/trunk/abstractions/ptz-camera/; revision=7484
-rw-r--r--membrane.py111
1 files changed, 111 insertions, 0 deletions
diff --git a/membrane.py b/membrane.py
new file mode 100644
index 0000000..084d904
--- /dev/null
+++ b/membrane.py
@@ -0,0 +1,111 @@
+import pyext
+import sys
+from numarray import *
+
+class tixel_coords(pyext._class):
+
+ # number of inlets and outlets
+ _inlets=1
+ _outlets=1
+
+ # Vars
+ numWide = float(4)
+ numHigh = float(3)
+ sectionWidth = float()
+ sectionHeight = float()
+ myarray = array()
+
+ print "tixel_coords init"
+
+ # Definitions
+
+ # Constructor
+
+ def __init__(self,*args):
+ if len(args) == 2:
+ self.numWide = args[0]
+ self.numHigh = args[1]
+
+ self.sectionWidth = 1.0/self.numWide
+ self.sectionHeight = 1.0/self.numHigh
+
+ self.myarray = arange(self.numWide*self.numHigh, shape=(self.numHigh,self.numWide), type=Int)
+
+ else:
+ print "External requires 4 arguments: <numWide> <numHeight>"
+
+ # methods for first inlet
+ def bang_(self,n):
+ for i in xrange(int(self.numWide)):
+ for j in xrange(int(self.numHigh)):
+ left = float(i)*self.sectionWidth
+ right = left + self.sectionWidth
+ bottom = float(j)*self.sectionHeight
+ top = bottom+self.sectionHeight
+ x = self.myarray[j,i]
+
+ # constructing list for each tixel
+ self._outlet(1,x,"coords",left,right,top,bottom)
+
+class int2bytes(pyext._class):
+
+ # number of inlets and outlets
+ _inlets=1
+ _outlets=4
+
+ print "int2bytes init"
+
+ # Constructor
+
+ # methods
+ def float_1(self,number):
+ number = int(number)
+ for count in xrange(4):
+ byte = (number & 0xF000) >> 12
+ number <<=4
+ self._outlet(count+1,byte)
+
+class seekArray3d(pyext._class):
+
+ # number of inlets and outlets
+ _inlets=1
+ _outlets=1
+
+ print "seekArray init"
+
+ # Vars
+ width = int()
+ height = int()
+ depth = int()
+ index = array()
+
+ # Constructor
+ def __init__(self,*args):
+ if len(args) == 3:
+ self.width = args[0]
+ self.height = args[1]
+ self.depth = args[2]
+
+ self.index = arange(self.width*self.height*self.depth,type=Int32,shape=(self.depth,self.height,self.width))
+ else:
+ print "you need to specify at least three aguments: <width> <height> <depth>"
+
+ # methods
+ def seek_1(self,*l):
+ if len(l) == 3:
+ zoom = l[0]
+ tilt = l[1]
+ pan = l[2]
+ position = self.index[zoom+1,tilt+1,pan]
+ self._outlet(1,position)
+ else:
+ print "you need to specify at least three aguments: seek <zoom> <tilt> <pan>"
+
+
+ def float_1(self,number):
+ number = int(number)
+ for count in xrange(4):
+ byte = (number & 0xF000) >> 12
+ number <<=4
+ self._outlet(count+1,byte)
+ \ No newline at end of file