We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Coordinate out of bounds! (Read 1371 times)
Coordinate out of bounds!
May 13th, 2010, 5:21pm
 
Total noob.  Trying to run the code below, but receiving this error:

ArrayIndexOutOfBoundsException: Coordinate out of bounds!  

This is all too new for me to figure out.  

I'm running Processing 1.1 on Ubuntu 9.10, with the gsvideo library.  
Here's my code:
Code:
import codeanticode.gsvideo.*;

//import processing.video.*; // import the video package

PFont font; // a reference to your font
GSMovie trashMovie; // a reference to your movie

// all of these files go in the "data/" directory
String movieFile = "test3.avi"; // the name of the video file
String timestampsFile = "timestamps_"+movieFile+".txt"; // the name of the ts file
String captionsFile = "captions.txt"; // the name of the captions file.


float[] timestamps; // an array of the loaded timestamps
String[] captionWords; // an array of the loaded caption words

void setup() {
size(640, 480); // set the size of the screen
trashMovie = new GSMovie(this, movieFile); // load the movie
trashMovie.loop(); // make it a looping movie

loadTimestamps(timestampsFile); // load the timestamps
loadCaptions(captionsFile); // load the caption(s)

font = loadFont("Serif-48.vlw"); // load th font
textFont(font,48); // set the font

}

// this is the main draw loop
void draw() {
image(trashMovie,0,0); // draw the video frame
String caption = getText(trashMovie.time()); // get the current caption
fill(255,255,0,200); // make the text yellowish
text(caption,10,240,620,240); // draw the text into a box

}



// returns as many words from the caption as there have been mouth movements
String getText(float time) {
int numberOfMouthMovementsSoFar = 0;
for(int i = 0; i < timestamps.length; i++) {
if(time >= timestamps[i]) {
numberOfMouthMovementsSoFar++;
}
else {
break;
}
}
StringBuffer sb = new StringBuffer();
for(int i = 0; i < numberOfMouthMovementsSoFar; i++) {
sb.append(captionWords[i%captionWords.length]); // wrap around
sb.append(" ");
}
return sb.toString();
}


// loads the timestamps from a file
void loadTimestamps(String t) {
String[] ts = loadStrings(t);
timestamps = new float[ts.length];
for(int i = 0; i < ts.length; i++) {
timestamps[i] = Float.parseFloat(ts[i]);
}
}

// loads the caption from a file
void loadCaptions(String c) {
String caption = loadStrings(captionsFile)[0]; // gets the first line in the file
captionWords = split(caption, " ");

}


void movieEvent(GSMovie moov) {
moov.read();
}



Re: Coordinate out of bounds!
Reply #1 - May 13th, 2010, 11:35pm
 
could you paste more of your error, and maybe highlight the line where it happens? do you have all the files needed? the timestamp, caption and movie file in the data directory ?
Page Index Toggle Pages: 1