Who Stole my cat's food?

I’ve explicitly stated it was from the sketch’s version 1.3: :expressionless:

Where paths is a Queue of File objects: :file_cabinet:

Well, the overloaded makeSnapshot() got a String folder parameter for it. :framed_picture:

Thanks a lot, I think we’re getting close.

I ended up using
final String fold = ClipIncrStr+"/";

And things were nice, the files were being saved in a new directory with each serial event.
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-03.1685.png
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-03.1686.png
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-03.1687.png
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-04.1688.png
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-04.1689.png
C:\Users\haral\Desktop\Timed_Recording\TimedRecording_05_FrameCount\data\004\2019-Sep-19.12-02-04.1690.png

I got very happy till I figured that the files were being deleted from old directories too.
Meaning I was hoping to find in \data\004\ 200 files left intact because now I m recording in 005.
The sketch kills them all in all directories .

What to do?
Thanks

The sketch I’ve provided is mono-folder, just like you had requested originally: :roll_eyes:

As a workaround for this new multi-folder requirement, you can try out invoking clear() every time you change folder, so files from previous folders are never delete() anymore: :negative_squared_cross_mark:

Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html#clear()

paths.clear()

Yey, that worked,

I just added it in the serial event:

  if ( ArduCOM_Port.available() > 0 ) { 
    IncomingByte = ArduCOM_Port.read(); 
    println (IncomingByte);
    if (IncomingByte==1)
    {
     // println("last: "+outfile);
      ClipIncr++;
      ClipIncrStr=(nf(ClipIncr,3)); 
      paths.clear();
      IncomingByte=0;
    }
  }

That is awesome. Never knew this file management system.
For mysterious reasons displayTitle function does not work anymore,
There is no stamp on the top of the pic. Would be nice to have.

I attached the whole sketch.


import java.io.File;

import java.text.SimpleDateFormat;
import java.util.Date;

import java.util.Queue;
import java.util.ArrayDeque;

static final String PATTERN = "yyyy-MMM-dd.HH-mm-ss.", EXT = ".png";
static final int MAX_FILES = 300, FPS = 30;


final Queue<File> paths = new ArrayDeque<File>(MAX_FILES);

import processing.video.*;
import java.awt.Font;
import java.awt.Rectangle;
PFont f;
PFont font;
int w= #FFFFFF; // white
int y= #FCF442; //yellow
int g= #A0FFA3; //green
int b= #64E1FF; // blue
int mg= #CC15D3; // Magenta
int o= #FF6C67;  // orange
int i= #B767FF; // indigo
int r= #FC0B03; // red
int bk = (#212121);  


int ClipIncr=0;
String ClipIncrStr="0";

import processing.serial.*;
Serial ArduCOM_Port; 

Capture cam;
int IncomingByte;


void setup() {
  size (640, 480, JAVA2D);
  font = loadFont("AgencyFB-Bold-200.vlw");

  String[] cameras = Capture.list();

  if (cameras == null) {
    println("Failed to retrieve the list of available cameras, will try the default...");
    cam = new Capture(this, 640, 480);
  } 
  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    printArray(cameras);

    // The camera can be initialized directly using an element
    // from the array returned by list():
    cam = new Capture(this, cameras[7]);
    // Or, the settings can be defined based on the text in the list
    //cam = new Capture(this, 640, 480, "Built-in iSight", 30);

    // Start capturing the images from the camera
    cam.start();
  }
  frameRate(30);
  ArduCOM_Port = new Serial(this, "COM4", 115200);
  // record=false;
}  //end setup

void draw() {
  // background(bk); 
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0, 640, 480);

  if ( ArduCOM_Port.available() > 0 ) { 
    IncomingByte = ArduCOM_Port.read(); 
    println (IncomingByte);
    if (IncomingByte==1)
    {
     // println("last: "+outfile);
      ClipIncr++;
      ClipIncrStr=(nf(ClipIncr,3)); 
      paths.clear();
      IncomingByte=0;
    }
  }

 
  
  makeSnapshot();
  displayTitle();
}

static final String getTimeStamp() 
{
  return new SimpleDateFormat(PATTERN).format(new Date());
}

void makeSnapshot() {
  makeSnapshot("");
}

void makeSnapshot(final String folder) {
  
 
  if (paths.size() == MAX_FILES)  
  paths.remove().delete();
  
 

  final String fold = ClipIncrStr+"/";
   //   folder == null || folder.isEmpty()? "" :
   // folder.endsWith("/") || folder.endsWith("\\")? folder :
   // folder + "/";

  final File newPath = dataFile(fold + getTimeStamp() + frameCount + EXT);
  println(newPath);

  paths.add(newPath);
  saveFrame(newPath.getPath());
}


void displayTitle() {
  final String msg =
    "Frame: " + frameCount +
    "  -  Size: " + paths.size() + 
    "  -  FPS: " + round(frameRate);

  surface.setTitle(msg);
}

Sorry about the last comment, I was expecting the DisplayTitle to put a stamp in the saved frames.
I can do that with text, I will figure it. It works fine for monitoring.
Next I will try to find an movie assembler so I dont have to generate all movies by hand from tools.

Any experience with that?
Thanks again

Got to play with it and it does the job. The indicated framerate is 14 to 16 but when I assemble the film, I have 300 PNGs that play back nice in 10 sec movie. It seems I am saving 30 frames per sec, even if the indicated framerate is lower. Go figure?!

I decided that is easier to move by hand all saved PNGs in one directory and make a big old film with all the events of the day. I might insert a 1/2 second of black screen at the beginning of each sequence.

The film assembles nicely despite the gaps in the frame numbers.

Am I driving everybody crazy by now? Sorry.

So, Wouldn’t it be nice to save all frames in a directory to start with? So I dont have to move them by hand at the end of the day.
At this point that is not possible due to the structure that deletes
if (paths.size() == MAX_FILES)
paths.remove().delete();

I have to think about this…
Thanks