Hi all,
I’m working on a sketch that will require hundreds of thousands of large (3200 x 5000px) images to be drawn. However, I am just beginning to build the code and I am referencing only 15 images (not thousands), and I’m already running out of memory.
Does anyone have any suggestions for how to make this program more efficient. I can tell you that it doesn’t need to run quickly. It could run at 0.1 frames per second if needed.
UPDATE: I tried increasing the available memory to 10,000, just to see if that would help, and it did seem to fix the problem. (Previously I had thought that the maximum memory you could dedicate was 2,024. It appears that has changed?)
None-the-less, I’m wondering if I should be going about this in a different way? Is there a more efficient way to deal with a database of hundreds of thousands of high-resolution images?
Thanks!
Here’s the code:
PImage[] SpecimensFrame = new PImage[5];
int frame = 0;
int numFrames = 5;
void setup() {
size(1280, 720);
background(175);
for (int i = 0; i < 5; i++) {
String fileName = i + ".jpg";
SpecimensFrame[i] = loadImage(fileName);
}
}
void draw() {
image(SpecimensFrame[frame], 0, 0);
frame++;
if (frame == numFrames) {
frame = 0;
}
saveFrame("line-######.png");
}
If I load the images in the setup as below, when the draw runs it should theoretically run much more quickly but even with 50 images the sketch runs out of memory.
void setup() {
size(1280, 720);
background(175);
for (int i = 0; i < 50; i++) {
String fileName = i + ".jpg";
SpecimensFrame[i] = loadImage(fileName);
}
}