So, for the past few days this code was working just fine, how I wanted it to. But now the webcam flashes between no camera and the picture every second. I tested the webcam in Cheese on ubuntu and it works fine. This is my code
Code:import codeanticode.gsvideo.*;
import processing.serial.*;
import processing.opengl.*;
GSCapture cam;
Serial behind;
PFont thefont;
PImage crosshair;
void setup() {
size(600, 400, OPENGL);
cam = new GSCapture(this, 352, 288);
thefont = loadFont("ArialNarrow-48.vlw");
crosshair = loadImage("crosshair.png");
textFont(thefont, 32);
println(Serial.list());
behind = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
background(0);
if (cam.available()) {
cam.read();
image(cam,124,56);
image(crosshair, 275,175);
}else{
fill(0,255,0);
text("No Camera", 230, 200);
}
//Title
fill(0,255,0);
text("Airsoft Robot", 230, 45);
//Video Border
stroke(255);
line(122, 54, 478, 54);
line(122, 54, 122, 346);
line(478, 54, 478, 346);
line(122, 346, 478, 346);
//Behind Sensor
stroke(255);
line(122, 370, 478, 370);
line(122, 370, 122, 395);
line(122, 395, 478, 395);
line(478,395, 478, 370);
//Serial View
while (behind.available() > 0){
fill(255,0,0);
int behindread = behind.read();
rect(124, 372, 352, 21);
}
}