I am using the sketch below, which creates a fire effect on motion detection when using a webcam. The problem is, I am trying to be able to see the live feed instead of black image and background. I keep changing parameters but with no success. Any thoughts?
import processing.video.*;
int numPixels;
int threshold = 50;
int[] currentPixels;
int[] lastGoodPixels;
int[] backgroundPixels;
Capture video;
PImage pg;
int effectWidth;
int effectHeight;
// This will contain the pixels used to calculate the fire effect
int[][] fire;
// Flame colors
color[] palette;
int[] calc1,calc2,calc3,calc4,calc5;
void setup()
{
// Change size to 320 x 240 if too slow at 640 x 480
size(640, 480, JAVA2D);
//size(320, 240, JAVA2D);
effectWidth = width/2;
effectHeight = height/2;
pg = createImage(effectWidth, effectHeight, RGB);
video = new Capture(this, effectWidth, effectHeight, 30);
frameRate(60);
numPixels = effectWidth * effectHeight;
// Create arrays to store the current and background image
backgroundPixels = new int[numPixels];
currentPixels = new int[numPixels];
lastGoodPixels = new int[numPixels];
calc1 = new int[effectWidth];
calc3 = new int[effectWidth];
calc4 = new int[effectWidth];
calc2 = new int[effectHeight];
calc5 = new int[effectHeight];
colorMode(HSB);
fire = new int[effectWidth][effectHeight];
palette = new color[255];
// Generate the palette
for(int x = 0; x < palette.length; x++) {
//Hue goes from 0 to 85: red to yellow
//Saturation is always the maximum: 255
//Lightness is 0..255 for x=0..128, and 255 for x=128..255