I need to export my processing program as an application. I'm accessing the images from separate folders but I need them to be all in one place in the application. Can this be done? Or do I need to add all the files individually?
A bit messy and repetitive, but here's my code.
PImage[] images1;
PImage[] images2;
PImage[] images3;
PImage[] images4;
String[] imageNames;
int imageCount = 0;
int ilength;
void setup() {
size(1376, 1008);
imageMode(CENTER);
background(255);
frameRate(1);
File dir1 = new File(sketchPath, "/face1");
if (dir1.isDirectory()) {
String[] contents = dir1.list();
ilength = contents.length;
images1 = new PImage[contents.length];
imageNames = new String[contents.length];
for (int i = 0 ; i < contents.length; i++) {
// skip hidden files and folders starting with a dot, load .png files only
if (contents[i].charAt(0) == '.') continue;
else if (contents[i].toLowerCase().endsWith(".jpg")) {
I'm trying to switch over some code to 2.0. It uses back ground subtraction from the capture library. The problem is that when I press a key to set the background nothing happens.
Heres the code:
import processing.video.*;
int numPixels;
int[] backgroundPixels;
Capture video;
int cellSize=0;
void setup() {
// Change size to 320 x 240 if too slow at 640 x 480
size(500, 500);
video = new Capture(this, width, height, 24);
numPixels = video.width * video.height;
// Create array to store the background image
backgroundPixels = new int[numPixels];
// Make the pixels[] array available for direct manipulation
loadPixels();
}
void draw() {
if (video.available()) {
video.read(); // Read a new video frame
video.loadPixels(); // Make the pixels of video available
// Difference between the current frame and the stored background
int presenceSum = 0;
for (int i = 0; i < numPixels; i++) { // For each pixel in the video frame...
// Fetch the current color in that location, and also the color
// of the background in that spot
color currColor = video.pixels[i];
color bkgdColor = backgroundPixels[i];
// Extract the red, green, and blue components of the current pixel’s color
int currR = (currColor >> 16) & 0xFF;
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
// Extract the red, green, and blue components of the background pixel’s color
int bkgdR = (bkgdColor >> 16) & 0xFF;
int bkgdG = (bkgdColor >> 8) & 0xFF;
int bkgdB = bkgdColor & 0xFF;
// Compute the difference of the red, green, and blue values
int diffR = abs(currR - bkgdR);
int diffG = abs(currG - bkgdG);
int diffB = abs(currB - bkgdB);
// Add these differences to the running tally
presenceSum += diffR + diffG + diffB;
// Render the difference image to the screen
//pixels[i] = color(diffR, diffG, diffB);
// The following line does the same thing much faster, but is more technical