Ich versuche herauszufinden, wie Sie den neuesten Ordner auswählen, erstellt zum Laden in PImage. Ich kann keinen Weg finden.Holen Sie den neuesten Ordner mit PImage (Verarbeitung)
ich zwei Skizzen habe, eine, die eine Reihe von Bildern erzeugt, und eine, die sie in lädt. Dies ist derjenige, der sie in lädt.
Ein neuer Ordner in meinen Skizze Datenordner jedes Mal erstellt wird, um das andere Skizzenläufe. Ich muss den zuletzt erstellten Ordner auswählen und in mein PImage laden. Es sieht aus wie http://imgur.com/a/u1jF0
So würde der Name des nächsten Ordners test_segments2 heißen, dann test segments3 ... und so weiter.
Code:
final int len = 25;
final float thresh = 170;
boolean newDesign = false;
PImage pic;
ArrayList<PImage> imgContainer;
int n = 1;
void setup() {
size(800, 800, P2D);
colorMode(RGB, 255);
background(250, 250, 250);
rectMode(CENTER);
// imageMode(CENTER);
pic = loadImage("hand.jpg");
pic.resize(width, height);
color c1 = color(200, 25, 25);
color c2 = color(25, 255, 200);
imgContainer = new ArrayList<PImage>();
PImage pimg1 = loadImage("THIS IS WHERE I NEED THE PATH OF MOST RECENT FOLDER CREATED TO GO");
pimg1.resize(50, 50);
noLoop();
noStroke();
}
void draw() {
if (newDesign == false) {
return;
}
pic.loadPixels();
for (int y = 0; y < height; y += 40) {
for (int x = 0; x < width; x += 40) {
int index = y * width + x;
color pixelValue = pic.pixels[index];
color rgb = pixelValue;
int r = (rgb >> 16) & 0xFF; // Faster way of getting red(argb)
int g = (rgb >> 8) & 0xFF; // Faster way of getting green(argb)
int b = rgb & 0xFF;
// How far is the current color from white
float dista = dist(r, g, b, 255, 255, 255);
// 50 is a threshold value allowing close to white being
// identified as white
// This value needs to be adjusted based on your actual
// background color
// Next block is processed only if the pixel not white
if (dista > 30) {
float pixelBrightness = brightness(pixelValue);
float imgPicked = constrain(pixelBrightness/thresh, 0, n - 1);
image(imgContainer.get((int) imgPicked), x, y);
}
}
}
}
void mouseReleased() {
newDesign=!newDesign;
redraw();
}
Ok cool. Von allen aufgeführten Dateitypen, die am besten funktionieren würden? Ich sehe filedatasoure, filefilter, filenamefilter ...? – guyintightpants
@guyintightpants Ich würde nur mit der 'File' Klasse beginnen. –
Oh, ich sehe es jetzt. Ich sehe lastModified .... wie bekomme ich die Metadaten über die Datei? – guyintightpants