Permalink
Browse files

Update to latest 2.0 beta. 50% of tests pass.

  • Loading branch information...
1 parent a938b66 commit 7d1ce740af4dd413a6ecef3e24c1210add8facf5 @jdf committed Oct 22, 2012
Showing 873 changed files with 4,253 additions and 32 deletions.
View
@@ -60,7 +60,7 @@
<target name="generate-driver"
description="Generate DriverImpl class">
- <java classpath="buildtime/lib/jython/jython.jar:buildtime/lib/processing/core.jar"
+ <java classpath="buildtime/lib/jython/jython.jar:buildtime/lib/processing/core.jar:libraries/processing/opengl/jogl-all.jar:libraries/processing/opengl/gluegen-rt.jar"
classname="org.python.util.jython"
fork="true">
<arg value="buildtime/py/cog.py"/>
Binary file not shown.
@@ -15,7 +15,7 @@
^(
screen|args|recorder|frame|g|selectedFile|keyEvent|mouseEvent
|sketchPath|screen(Width|Height)|defaultSize|firstMouse|finished
- |requestImageMax
+ |requestImageMax|online
)$
''', re.X)
@@ -31,7 +31,8 @@
|(get|set|remove)Cache|update|destroy|main|flush|addListeners|dataFile
|die|setup|mouseE(ntered|xited)|paint|sketch[A-Z].*|stop|save(File|Path)
|displayable|method|runSketch|start|focus(Lost|Gained)|(data|create)Path
- |round|abs|max|min|open|append|splice|expand|contract|set|exit
+ |round|abs|max|min|open|append|splice|expand|contract|set|exit|link|param
+ |status
)$
''', re.X)
@@ -58,10 +59,11 @@ def prim(type_name):
We want to create Jython wrappers for all public methods of PApplet except
those in "BAD_METHOD". Also, if we have both foo(int) and foo(char), we throw
away the char variant, and always call the int variant. Same with foo(byte).
-Sadly, Java has no unisgned types, so the distinction is weird.
+Sadly, Java has no unsigned types, so the distinction is weird.
"""
WANTED_METHODS = [m for m in Class.getDeclaredMethods(PApplet)
if Modifier.isPublic(m.getModifiers())
+ and not m.getExceptionTypes()
and not BAD_METHOD.match(m.getName())
and not any(k in USELESS_TYPES for k in m.getParameterTypes())]
@@ -104,10 +106,14 @@ def __init__(self, to_python_prefix, to_java_format, typecheck_format):
'(%(name)s == PyFloat.TYPE '
'|| %(name)s == PyInteger.TYPE '
'|| %(name)s == PyLong.TYPE)'),
+ PRIMITIVES['double']:
+ ClassConversionInfo('new PyFloat',
+ '%s.asDouble()',
+ '%(name)s == PyFloat.TYPE'),
PRIMITIVES['long']:
ClassConversionInfo('new PyLong',
'%s.asLong()',
- None),
+ '%(name)s == PyLong.TYPE'),
Class.forName("java.lang.String"):
ClassConversionInfo('new PyUnicode',
'%s.asString()',
@@ -23,6 +23,7 @@ package jycessing;
import org.python.util.InteractiveConsole;
import org.python.core.*;
import processing.core.*;
+import processing.opengl.*;
import java.io.*;
@SuppressWarnings("serial")
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
-2.0.2
+3.0 BETA
Binary file not shown.
@@ -1,19 +0,0 @@
-# If you want to support more platforms, see the jogl.dev.java.net to get the
-# natives libraries for the platform in question (i.e. solaris). Then, add it
-# them to the applet line for export. For applications, you'll have to make the
-# changes by hand, i.e. use the linux version of the export, and modify its
-# contents to include the necessary files for your platform.
-
-name = OpenGL
-
-application.macosx = opengl.jar, jogl.jar, libjogl.jnilib, libjogl_awt.jnilib, libjogl_cg.jnilib, gluegen-rt.jar, libgluegen-rt.jnilib
-
-application.windows = opengl.jar, jogl.jar, jogl.dll, jogl_awt.dll, jogl_cg.dll, gluegen-rt.jar, gluegen-rt.dll
-
-application.linux = opengl.jar, jogl.jar, gluegen-rt.jar, libjogl.so, libjogl_awt.so, libjogl_cg.so, libgluegen-rt.so
-
-# In releases later than (but not including) 1.0.9, the applet JAR files
-# are downloaded directly from Sun, so that a single version is cached
-# on the user's computer, rather than increasing the download size with
-# the versions for each platform.
-applet = opengl.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
+name = Serial I/O
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<project name="Processing Video Library" default="build">
+
+ <target name="clean" description="Clean the build directories">
+ <delete dir="bin" />
+ <delete file="library/video.jar" />
+ </target>
+
+ <target name="compile" description="Compile sources">
+ <condition property="core-built">
+ <available file="../../../core/library/core.jar" />
+ </condition>
+ <fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" />
+
+ <mkdir dir="bin" />
+ <javac source="1.6"
+ target="1.6"
+ srcdir="src" destdir="bin"
+ encoding="UTF-8"
+ includeAntRuntime="false"
+ classpath="../../../core/library/core.jar; library/gstreamer-java.jar; library/jna.jar" />
+ </target>
+
+ <target name="build" depends="compile" description="Build video library">
+ <jar basedir="bin" destfile="library/video.jar" />
+ </target>
+</project>
@@ -0,0 +1,136 @@
+/**
+ * ASCII Video
+ * by Ben Fry.
+ *
+ *
+ * Text characters have been used to represent images since the earliest computers.
+ * This sketch is a simple homage that re-interprets live video as ASCII text.
+ * See the keyPressed function for more options, like changing the font size.
+ */
+
+import processing.video.*;
+
+Capture video;
+boolean cheatScreen;
+
+// All ASCII characters, sorted according to their visual density
+String letterOrder =
+ " .`-_':,;^=+/\"|)\\<>)iv%xclrs{*}I?!][1taeo7zjLu" +
+ "nT#JCwfy325Fp6mqSghVd4EgXPGZbYkOA&8U$@KHDBWNMR0Q";
+char[] letters;
+
+float[] bright;
+char[] chars;
+
+PFont font;
+float fontSize = 1.5;
+
+
+void setup() {
+ size(640, 480, P2D);
+
+ // Uses the default video input, see the reference if this causes an error
+ video = new Capture(this, 160, 120);
+ video.start();
+ int count = video.width * video.height;
+ println(count);
+
+ font = loadFont("UniversLTStd-Light-48.vlw");
+
+ // for the 256 levels of brightness, distribute the letters across
+ // the an array of 256 elements to use for the lookup
+ letters = new char[256];
+ for (int i = 0; i < 256; i++) {
+ int index = int(map(i, 0, 256, 0, letterOrder.length()));
+ letters[i] = letterOrder.charAt(index);
+ }
+
+ // current characters for each position in the video
+ chars = new char[count];
+
+ // current brightness for each point
+ bright = new float[count];
+ for (int i = 0; i < count; i++) {
+ // set each brightness at the midpoint to start
+ bright[i] = 128;
+ }
+}
+
+
+void captureEvent(Capture c) {
+ c.read();
+}
+
+
+void draw() {
+ background(0);
+
+ pushMatrix();
+
+ float hgap = width / float(video.width);
+ float vgap = height / float(video.height);
+
+ scale(max(hgap, vgap) * fontSize);
+ textFont(font, fontSize);
+
+ int index = 0;
+ video.loadPixels();
+ for (int y = 1; y < video.height; y++) {
+
+ // Move down for next line
+ translate(0, 1.0 / fontSize);
+
+ pushMatrix();
+ for (int x = 0; x < video.width; x++) {
+ int pixelColor = video.pixels[index];
+ // Faster method of calculating r, g, b than red(), green(), blue()
+ int r = (pixelColor >> 16) & 0xff;
+ int g = (pixelColor >> 8) & 0xff;
+ int b = pixelColor & 0xff;
+
+ // Another option would be to properly calculate brightness as luminance:
+ // luminance = 0.3*red + 0.59*green + 0.11*blue
+ // Or you could instead red + green + blue, and make the the values[] array
+ // 256*3 elements long instead of just 256.
+ int pixelBright = max(r, g, b);
+
+ // The 0.1 value is used to damp the changes so that letters flicker less
+ float diff = pixelBright - bright[index];
+ bright[index] += diff * 0.1;
+
+ fill(pixelColor);
+ int num = int(bright[index]);
+ text(letters[num], 0, 0);
+
+ // Move to the next pixel
+ index++;
+
+ // Move over for next character
+ translate(1.0 / fontSize, 0);
+ }
+ popMatrix();
+ }
+ popMatrix();
+
+ if (cheatScreen) {
+ //image(video, 0, height - video.height);
+ // set() is faster than image() when drawing untransformed images
+ set(0, height - video.height, video);
+ }
+}
+
+
+/**
+ * Handle key presses:
+ * 'c' toggles the cheat screen that shows the original image in the corner
+ * 'g' grabs an image and saves the frame to a tiff image
+ * 'f' and 'F' increase and decrease the font size
+ */
+void keyPressed() {
+ switch (key) {
+ case 'g': saveFrame(); break;
+ case 'c': cheatScreen = !cheatScreen; break;
+ case 'f': fontSize *= 1.1; break;
+ case 'F': fontSize *= 0.9; break;
+ }
+}
@@ -0,0 +1,69 @@
+/**
+ * Background Subtraction
+ * by Golan Levin.
+ *
+ * Detect the presence of people and objects in the frame using a simple
+ * background-subtraction technique. To initialize the background, press a key.
+ */
+
+
+import processing.video.*;
+
+int numPixels;
+int[] backgroundPixels;
+Capture video;
+
+void setup() {
+ // Change size to 320 x 240 if too slow at 640 x 480
+ size(640, 480, P2D);
+
+ video = new Capture(this, width, height);
+ video.start();
+ numPixels = video.width * video.height;
+ // Create array to store the background image
+ backgroundPixels = new int[numPixels];
+ // Make the pixels[] array available for direct manipulation
+ loadPixels();
+}
+
+void draw() {
+ if (video.available()) {
+ video.read(); // Read a new video frame
+ video.loadPixels(); // Make the pixels of video available
+ // Difference between the current frame and the stored background
+ int presenceSum = 0;
+ for (int i = 0; i < numPixels; i++) { // For each pixel in the video frame...
+ // Fetch the current color in that location, and also the color
+ // of the background in that spot
+ color currColor = video.pixels[i];
+ color bkgdColor = backgroundPixels[i];
+ // Extract the red, green, and blue components of the current pixel�s color
+ int currR = (currColor >> 16) & 0xFF;
+ int currG = (currColor >> 8) & 0xFF;
+ int currB = currColor & 0xFF;
+ // Extract the red, green, and blue components of the background pixel�s color
+ int bkgdR = (bkgdColor >> 16) & 0xFF;
+ int bkgdG = (bkgdColor >> 8) & 0xFF;
+ int bkgdB = bkgdColor & 0xFF;
+ // Compute the difference of the red, green, and blue values
+ int diffR = abs(currR - bkgdR);
+ int diffG = abs(currG - bkgdG);
+ int diffB = abs(currB - bkgdB);
+ // Add these differences to the running tally
+ presenceSum += diffR + diffG + diffB;
+ // Render the difference image to the screen
+ pixels[i] = color(diffR, diffG, diffB);
+ // The following line does the same thing much faster, but is more technical
+ //pixels[i] = 0xFF000000 | (diffR << 16) | (diffG << 8) | diffB;
+ }
+ updatePixels(); // Notify that the pixels[] array has changed
+ println(presenceSum); // Print out the total amount of movement
+ }
+}
+
+// When a key is pressed, capture the background image into the backgroundPixels
+// buffer, by copying each of the current frame�s pixels into it.
+void keyPressed() {
+ video.loadPixels();
+ arraycopy(video.pixels, backgroundPixels);
+}
@@ -0,0 +1,58 @@
+/**
+ * Brightness Thresholding
+ * by Golan Levin.
+ *
+ * Determines whether a test location (such as the cursor) is contained within
+ * the silhouette of a dark object.
+ */
+
+
+import processing.video.*;
+
+color black = color(0);
+color white = color(255);
+int numPixels;
+Capture video;
+
+void setup() {
+ size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
+ strokeWeight(5);
+ // Uses the default video input, see the reference if this causes an error
+ video = new Capture(this, width, height);
+ video.start();
+ numPixels = video.width * video.height;
+ noCursor();
+ smooth();
+}
+
+void draw() {
+ if (video.available()) {
+ video.read();
+ video.loadPixels();
+ int threshold = 127; // Set the threshold value
+ float pixelBrightness; // Declare variable to store a pixel's color
+ // Turn each pixel in the video frame black or white depending on its brightness
+ loadPixels();
+ for (int i = 0; i < numPixels; i++) {
+ pixelBrightness = brightness(video.pixels[i]);
+ if (pixelBrightness > threshold) { // If the pixel is brighter than the
+ pixels[i] = white; // threshold value, make it white
+ }
+ else { // Otherwise,
+ pixels[i] = black; // make it black
+ }
+ }
+ updatePixels();
+ // Test a location to see where it is contained. Fetch the pixel at the test
+ // location (the cursor), and compute its brightness
+ int testValue = get(mouseX, mouseY);
+ float testBrightness = brightness(testValue);
+ if (testBrightness > threshold) { // If the test location is brighter than
+ fill(black); // the threshold set the fill to black
+ }
+ else { // Otherwise,
+ fill(white); // set the fill to white
+ }
+ ellipse(mouseX, mouseY, 20, 20);
+ }
+}
Oops, something went wrong.

0 comments on commit 7d1ce74

Please sign in to comment.