I run code and it's ok, but I don't have the light and sting letter. I also see video camera me.
The problem. I want to used the light and sting letter.
Where is mistake?
How can I do?
/* Examples
Video --> AsciiVideo
Topics --> Image Processing --> Brightness
*/
//Brightness AsciiVideo
import processing.video.*;
Capture video;
boolean cheatScreen;
// All ASCII characters, sorted according to their visual density
String letterOrder =
"0";
char[] letters;
float[] bright;
char[] chars;
PFont font;
float fontSize = 1.5;
void setup() {
size(640, 480, P2D);
// Or run full screen, more fun! Use with Sketch -> Present
//size(screen.width, screen.height, OPENGL);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 15);
int 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
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;
}
video.loadPixels();
loadPixels();
}
void draw() {
video.read();
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;
for (int y = 1; y < video.height; y++) {
translate(0, 1.0 / fontSize);
pushMatrix();
for (int x = 0; x < video.width; x++) {
int pixelColor = video.pixels[index];
float r1 = (pixelColor >> 16) & 0xff;
float g2 = (pixelColor >> 8) & 0xff;
float b3 = pixelColor & 0xff;
float pixelBright = max(r1, g2, b3);
float diff = pixelBright - bright[index];
bright[index] += diff *0.1;
fill(pixelColor);
int num = int(bright[index]);
text(letters[num], 0, 0);
index++;
translate(1.0 / fontSize, 0);
int loc = x + y*video.width;
//float r1, g2, b3;
r1 = red (video.pixels[loc]);
float maxdist = 50;//dist(0,0,width,height);
float d = dist(x,y,mouseX,mouseY);
float adjustbrightness = 255*(maxdist-d)/maxdist;
r1 += adjustbrightness;
//g5 += adjustbrightness;
//b6 += adjustbrightness;
// Constrain RGB to make sure they are within 0-255 color range
//r4 = constrain(r4,0,255);
//g5 = constrain(g5,0,255);
//b6 = constrain(b6,0,255);
// Make a new color and set pixel in the window
//color c = color(r4,g5,b6);
color c = color(r1);
pixels[y*width + x] = c;
}
popMatrix();
}
popMatrix();
if(cheatScreen) {
set(0, height - video.height, video);
}
video.updatePixels();
}
/**
* 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