getting a lot of fatal errors and program stops running
in
Contributed Library Questions
•
3 years ago
Hello,
I'm writing a program that tracks a color on a blue screen and depending on which part of the screen the color is on, it plays a little tone (i.e. - person with red dot on leg moves around and some sounds play while a little yellow dot moves along a blue screen)
The program is constantly crashing and won't run for very long. I get # A fatal error has been detected by the Java Runtime Ennironment: EXCEPTION_ACCESS_VIOLATION (0x0000005 at pc=0x7c342eee, pid = 4680, tid=3988 etc etc etc etc...
Thanks so much for any help!
here is the code:
I'm writing a program that tracks a color on a blue screen and depending on which part of the screen the color is on, it plays a little tone (i.e. - person with red dot on leg moves around and some sounds play while a little yellow dot moves along a blue screen)
The program is constantly crashing and won't run for very long. I get # A fatal error has been detected by the Java Runtime Ennironment: EXCEPTION_ACCESS_VIOLATION (0x0000005 at pc=0x7c342eee, pid = 4680, tid=3988 etc etc etc etc...
Thanks so much for any help!
here is the code:
- /**
* Color Tracking code mostly by: Justin Brooks based on original code: Brightness Tracking by Golan Levin.
*
* Tracks the pixel closest in color to specified color and makes a sound depending in which quadrant the color is in...sound stuff by me.
*/
import codeanticode.gsvideo.*;
import ddf.minim.*;
Minim minim;
AudioSample[] snip = new AudioSample[15];
GSCapture video;
int dl = 300;
void setup() {
size(320, 240); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height, 30);
//noStroke();
smooth();
minim = new Minim(this);
for (int i = 1; i < snip.length; i++) {
snip[i] = minim.loadSample("samp" + i + ".wav");
}
}
void draw() {
background(0,0,255);
stroke(0);
float two = width*.5;
float one = width*.25;
float three = width*.75;
line(one, 0, one ,height);
line(two, 0, two, height);
line(three, 0, three, height);
if (video.available()) {
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int colorX = 0; // X-coordinate of the closest in color video pixel
int colorY = 0; // Y-coordinate of the closest in color video pixel
float closestColor = 10000; //we set this to be abritrarily large, once program runs, the first pixel it scans will be set to this value
// Search for the closest in color pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
color pixelValue = video.pixels[index];
// Determine the color of the pixel
float colorProximityBox = abs(red(pixelValue)-255)+abs(green(pixelValue)-0)+abs(blue(pixelValue)-0);
// If that value is closer in color value than any previous, then store the
// color proximity of that pixel, as well as its (x,y) location
if (colorProximityBox < closestColor) {
closestColor = colorProximityBox;
closestColor=closestColor-5; //was 10 ...thoguht behind this is that it once it "locks" on to an object of color, it wont let go unless something a good bit better (closer in color) comes along
colorY = y;
colorX = x;
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel
fill(255, 204, 0, 128);
noStroke();
ellipse(colorX, colorY, 30, 30);
if (colorX < one) {
println("FIRST CHAMBER");
snip[3].trigger();
delay(dl);
}
if ((colorX > one)&&(colorX<two)) {
println("SECOND CHAMBER");
snip[4].trigger();
delay(dl);
}
if ((colorX>two)&&(colorX<three)) {
println("THIRD CHAMBER");
snip[10].trigger();
delay(dl);
}
if (colorX>three) {
println("FOURTH CHAMBER");
snip[6].trigger();
delay(dl);
}
}
}
1