Article View: es.comp.lenguajes.java
Article #712Ayuda con "processing 1.0"
From: zero cold
Date: Sun, 28 Jan 2007 23:37
Date: Sun, 28 Jan 2007 23:37
171 lines
6012 bytes
6012 bytes
Hola lista:
Acabo de suscribirme a esta lista ya que tengo un dilema:
Quiero generar una película ascii de una normal (avi, mpeg, etc) y en
la red encontre que alguien lo habia hecho utilizando este programa
"processing" el cual te genera código en java para exportarlo a
cualquier sistema...
El caso es que tiene un ejemplo para crear ascii video y no lo
entiendo mucho...,
-----------------------------------------------------------------------
----------------------------------------------------------------------
/**
* 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.opengl.*;
import processing.video.*;
Capture video;
int count;
boolean cheatScreen;
// all ascii characters, sorted according to their visual density
static final String vals =
" .`-_':,;^=+/\"|)\\<>)iv%xclrs{*}I?!][1taeo7zjLu" +
"nT#JCwfy325Fp6mqSghVd4EgXPGZbYkOA&8U$@KHDBWNMR0Q";
// how quickly to update each pixel (see below)
static final float STEP = 0.01;
// starting font size
float asciiFontSize = 1.5f;
float dgR[], dgG[], dgB[];
char values[];
float bright[];
char chars[];
PFont font;
public void setup() {
// run at the default size
size(640, 480, P3D);
// or run full screen, more fun!
//size(screen.width, screen.height, OPENGL);
video = new Capture(this, 80, 60, 15);
count = video.width * video.height;
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
values = new char[256];
float multiplier = 256.0 / (float) vals.length();
for (int i = 0; i < 256; i++) {
int which = values[i] = vals.charAt((int) (i / multiplier));
}
// 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.0f;
}
}
public void captureEvent(Capture c) {
c.read();
}
void draw() {
background(0);
pushMatrix();
float hgap = (float) width / (float) video.width;
float vgap = (float) height / (float) video.height;
scale(max(hgap, vgap) * asciiFontSize);
textFont(font, asciiFontSize);
int index = 0;
for (int y = 1; y < video.height; y++) {
// move down for next line
translate(0, 1.0 / asciiFontSize);
pushMatrix();
for (int x = 0; x < video.width; x++) {
int pixelColor = video.pixels[index];
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 brightness = max(r, g, b);
// the STEP variable is used to damp the changes so that letters
flicker less
bright[index] =
(bright[index] * (1.0 - STEP) + (float)brightness * STEP);
fill(pixelColor);
text((char) values[(int) bright[index]], 0, 0);
index++;
// move over for next character
translate(1.0 / asciiFontSize, 0);
}
popMatrix();
}
popMatrix();
if (cheatScreen) {
image(video, 0, height - video.height);
}
}
/**
* 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
*/
public void keyPressed() {
switch (key) {
case 'g': saveFrame(); break;
case 'c': cheatScreen = !cheatScreen; break;
case 'f': asciiFontSize *= 1.1f; break;
case 'F': asciiFontSize *= 0.9f; break;
}
}
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-------
Cuando lo ejecuto tal cual esta me genera este error:
Exception in thread "Thread-2" java.lang.NoClassDefFoundError:
quicktime/std/StdQTException
at Temporary_3340_744.setup(Temporary_3340_744.java:44)
Como ven este es el código que me genera; si me pueden ayudar a
convertir cualquier video a ascii se los agradecere mucho...
y esta es la página donde se encuentra el programa: http://
processing.org/
Technical Details
Message-ID:
<1170027472.786480.130070@h3g2000cwc.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,bc727f0903a82f63,start X-Google-Attributes: gid1116f3,public X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mail From: "zero cold" <zero.cold05@gmail.com> Newsgroups: es.comp.lenguajes.java Subject: Ayuda con "processing 1.0" Date: 28 Jan 2007 15:37:52 -0800 Organization: http://groups.google.com Lines: 172 Message-ID: <1170027472.786480.130070@h3g2000cwc.googlegroups.com> NNTP-Posting-Host: 190.53.0.140 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1170027479 4326 127.0.0.1 (28 Jan 2007 23:37:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 28 Jan 2007 23:37:59 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.1) Gecko/20061204 Firefox/2.0 MEGAUPLOAD 1.0,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h3g2000cwc.googlegroups.com; posting-host=190.53.0.140; posting-account=TiJ6EA0AAADe2RYmv4eObbY4LCM6asDb