What I am trying to do use this as a foundation but use a 2D array instead. my goal is to put myArray[i][j] in a mousePressed loop so when I click the mouse it will take a capture of the current frame. My second goal is when the mouse is pressed again it will take the color values of the first mouse click and average it with the second mouse click to create a composite image of the two.
my (erroneous) code is here:
import processing.video.*;
int videoScale = 8;
int cols, rows;
int myArray[][] = new int [cols][rows];
Capture video;
//Capture myCapture;
void setup() {
size(640, 480);
// myCapture = new Capture(this, width, height, 30);
cols = width/videoScale;
rows = height/videoScale;
video = new Capture (this,cols,rows, 30);
}
void draw() {
if (video.available()) {
video.read();
}
video.loadPixels();
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
int x = i*videoScale;
int y = j*videoScale;
color c = video.pixels[i+j*video.width];
myArray[i][j] = c + myArray[i][j];
fill(c);
// fill(c);
// noStroke();
// rect(x,y,videoScale, videoScale);
}
}
}
void keyPressed() {
if (key == CODED) {
switch(keyCode) {
case LEFT:
videoScale += 1;
break;
case RIGHT:
videoScale -= 1;
break;
}
}
}
void mousePressed() {
// image(myCapture, 0, 0);
}
Please help I have tried to solve this myself by am too big a noobie