I'm currently trying to consistently monitor a specific area of a PImage for it's color values, and pull XY coordinates of the first pixel to flag a change.
Example: A thresholded video is playing, I want to monitor a specific area, and pull the coordinates of the first pixel that changes from black to white. This will be used for a rudimentary collision detection/reaction.
I can call the PImage.get() function, and return the range of pixels that I want to monitor, but I cannot figure out what kind of data is stored in the resulting array.
Right now I just have (mostly for troubleshooting, that won't be in the final code)
printArray(colTest.get(box.bx, box.by, box.bW, box.bH));
just to show me the data but I cannot figure out what kind of data it is for me to actually run analysis on it.
The data from the PImage.get(x,y) is in readable color data, but the PImage.get(x,y,length,width) returns something like this:
processing.core.PImage@693b37ff
processing.core.PImage@607f247e
processing.core.PImage@677753c3
processing.core.PImage@1474d906
processing.core.PImage@13ef5435
processing.core.PImage@7a9ed6d7
processing.core.PImage@4e0c4bff
processing.core.PImage@4151f866
processing.core.PImage@6ad24b6a
processing.core.PImage@539fb47b
processing.core.PImage@2f0d635d
processing.core.PImage@251de095
processing.core.PImage@b5745d
processing.core.PImage@20991a01
processing.core.PImage@42b10fa9
...
Looking into the PImage.get(range) function, it returns a PImage. I'm wondering if there's a way to decode that data into either color or alpha data.
This goes on (non-repeating from what it seems) forever until the video loops. I've called the PImage.pixel[] array, but it is just so much data that I think it'll slow me down too much to have to comb through it every frame. My theory is that it would be much easier on the processor to just monitor a specific area (or areas) and return just those values rather than updating, accessing, analyzing, and returning results from the entire Pixel[] array every frame.
In order to reproduce this output, you can use this:
PImage img;
void setup() {
size(500, 500);
img = createImage(250, 250, RGB);
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++) {
img.pixels[i] = color(0);
}
imageMode(CENTER);
img.updatePixels();
}
void draw() {
image(img, width / 2, height / 2);
println(img.get((width / 2),(height / 2), 50, 50));
}