Pankyrou
YaBB Newbies
Offline
Posts: 9
Need Help with video Streamin Boxes above text
Apr 12th , 2010, 3:24am
Hey guys , I am working on a program for an exhibition . The main idea is to combine text mosaic and above that to have some boxes of the real video (with a small offset) this is what i got : 1st tab: " import processing.video.*; Capture video; Box[] boxArray = new Box[25]; int f=0; //create class Mosaic Mosaic myMosaic; void setup() { size(640,480); video = new Capture(this,640,480,15); //define class Mosaic myMosaic = new Mosaic(); for(int i = 0; i<boxArray.length; i++) { boxArray[i] = new Box(); } frameRate(30); } void draw() { //create an if/else form to animate the boxes depenting on the frame count if (video.available()) { video.read(); } //call class Mosaic myMosaic.display(); //image(video,0,0); //image(video,0,0); int moveCounter = int(random(0, boxArray.length)); boxArray[moveCounter].move(); for(int i = 0; i<boxArray.length; i++) { //if(frameCount == 1+f) if(frameCount%25==0) { //f = f+24; //if(i%2 == 0) boxArray[i].move(); //else if(i%2 == 1) boxArray[i].move(); } else { // boxArray[i].display(); } //boxArray[i].move(); boxArray[i].display(); } } " 2nd tab (class for the video boxes):" class Box { int Xpos; int Ypos; int BoxW; int BoxH; int cols; int rows; int visibleCounter; //this is freek jans code for the PImage public final static int visibleWindow = 5; public final static int lifeTime = 200; int birth; int speed = 4; PImage img; boolean visible; Box() { Xpos = int(random(100,540)); Ypos = int(random(100,380)); BoxW = int(random (50,100)); BoxH = int(random (50,100)); cols = int(Xpos/10); rows = int(Ypos/10); visible = true; birth = millis(); img = createImage(BoxW, BoxH, ARGB); } //try to animate the box by making a method for a different position void move() { Xpos = int(random(10,540)); Ypos = int(random(100,380)); //int(Xpos+random(0,200)); //Ypos = int(Xpos+random(0,150)); } void display() { int i; int j; int originalLoc; int offsetLoc; color c; noStroke(); video.loadPixels(); for (i = 0; i<BoxW; i++) { for(j = 0; j<BoxH; j++) { int pixLocation; c = video.pixels[(Xpos + i -10) + (j + Ypos) * video.width]; img.pixels[i + j*BoxW] = color(red(c),0,0); } } img.updatePixels(); if(alive() || true) { image(img, Xpos, Ypos, BoxW, BoxH); } } public boolean alive() { return (millis() - birth / 1000) < lifeTime; } } " 3rd tab (Class for the text Mosaic):" class Mosaic { import processing.video.*; // Size of each cell in the grid, ratio of window size to video size int videoScale = 10; // Number of columns and rows in our system int cols, rows; // Variable to hold onto capture object Capture video; // The source text used in the mosaic pattern. A longer String might produce more interesting results. String chars = "Kirou-Furs" ; PFont f; Mosaic() { size(640,480); // Set up columns and rows cols = width/videoScale; rows = height/videoScale; video = new Capture(this,cols,rows,15); // Load the font // Using a fixed-width font. In most fonts, individual characters have different widths. // In a fixed-width font, all characters have the same width. // This is useful here since we intend to display the letters one at a time spaced out evenly. // See Section 17.7 for how to display text character by character with a nonfixed width font. f = createFont("ArialHebrew-Bold",8,true); textFont(f); } void display() { background(0); // Read image from the camera if (video.available()) { video.read(); } video.loadPixels(); // Use a variable to count through chars in String int charcount = 0; // Begin loop for rows for (int j = 0; j < rows; j ++ ) { // Begin loop for columns for (int i = 0; i < cols; i ++ ) { // Where are we, pixel-wise? int x = i*videoScale; int y = j*videoScale; // Looking up the appropriate color in the pixel array color c = video.pixels[i + j*video.width]; // Displaying an individual character from the String instead of a rectangle textFont(f); fill(c); // Map the brightness of a pixel to the size of a font float b = brightness(video.pixels[i + j*video.width]); float fontSize = 20 * (b / 255); textSize(fontSize); // One character from the source text is displayed colored accordingly to the pixel location. // A counter variable -- charcount -- is used to walk through the source String one character at a time. text(chars.charAt(charcount),x,y); // Go on to the next character charcount = (charcount + 1) % chars.length(); } } } } " The problem is that i constantly get an error in the 3rd tab and i don't get it: "The constructor Capture(kirou_furs_3tabs.Mosaic,int,int,int)" is undefined " the video offset boxes and the mosaic work perfect separate can you help (im a bit new in porcessing)