Multiple recording and with Kinect and SimpleOpenNI

edited January 2014 in Kinect

Hi everyone,

Here is my issue: I am trying to set up more than one recording of the depth map. (When I am saying multiple recording I mean having more than one .oni file in the folder data at the end). I am using the recording/playing example of the Simple Open NI library. I managed to set up two recordings with a one minute gap between them but even if I am launching again the recording set up with a new file name for the recording I have only one file at the end of the program with the two recordings in it.

Do I have to use "context.close();" ? (I tried but it's stopping the program then)... Do I have to create a new context ?

Hope some can help me (I am using processing 2.1 on windows 7).

Here is my program. The starting time and ending time of each recording are set up in a .csv file.

import SimpleOpenNI.*;


SimpleOpenNI  context;
boolean Recording= false;
boolean Setup= false;
int Start= 0;
Table RecordingSet;
int SetNumber;

void setup()
{

  RecordingSet = loadTable("RecordingSet.csv");
  size(680, 320, JAVA2D);



  //context = new SimpleOpenNI(this);
  Reading();

  // set window size 
  if ((context.nodes() & SimpleOpenNI.NODE_DEPTH) != 0)
  {
    size(context.depthWidth()+300, context.depthHeight());
  }
}

void draw()
{


  // update
   //println("Going to be updated");
  context.update(); 
// println("updated");

  background(0, 0, 0);

  // draw the cam data
  if ((context.nodes() & SimpleOpenNI.NODE_DEPTH) != 0)
  {
    image(context.depthImage(), 300, 0);
  }


  if (RecordingSet.getRowCount()!=0) {
    for (int i =0;i<RecordingSet.getRowCount();i++) {
      DisplayNewRecordingValue(RecordingSet.getInt(i, 0), RecordingSet.getInt(i, 1), RecordingSet.getInt(i, 2), RecordingSet.getInt(i, 3), RecordingSet.getInt(i, 4), RecordingSet.getInt(i, 5), RecordingSet.getInt(i, 6), i);
      if (Recording==false) {
        if (RecordingSet.getInt(i, 0)==day() && RecordingSet.getInt(i, 1)==month() && RecordingSet.getInt(i, 2)==year() && RecordingSet.getInt(i, 3)==hour() && RecordingSet.getInt(i, 4)==minute()) {
          Recording=true;
          SetNumber=i;
        }
      }
    }
  }
  if (Recording==true) {

    if (Setup==false) {
      Setup=true;
      Recording(RecordingSet.getString(SetNumber, 7)+"_"+str(RecordingSet.getInt(SetNumber, 0))+"."+str(RecordingSet.getInt(SetNumber, 1))+"."+str(RecordingSet.getInt(SetNumber, 2))+"_"+str(RecordingSet.getInt(SetNumber, 3))+"."+str(RecordingSet.getInt(SetNumber, 4))+"_"+str(RecordingSet.getInt(SetNumber, 5))+"."+str(RecordingSet.getInt(SetNumber, 6)));
    }

    fill(255, 0, 0);
    ellipse(320, 20, 15, 15);

    if (RecordingSet.getInt(SetNumber, 5)==hour() && RecordingSet.getInt(SetNumber, 6)==minute()) {
      Recording=false;
      Setup=false;

//context.close();



      if (RecordingSet.getRowCount()==1) {
        RecordingSet.removeRow(SetNumber);
        saveTable(RecordingSet, "data/"+"RecordingSet.csv");
        exit();
      }
      else {
        RecordingSet.removeRow(SetNumber);
        saveTable(RecordingSet, "data/"+"RecordingSet.csv");
      }

//context = new SimpleOpenNI(this);
 context.addNodeToRecording(SimpleOpenNI.NODE_DEPTH,false);
 //  context.addNodeToRecording(SimpleOpenNI.NODE_IMAGE,false);
//Reading();
      //setup();
    }
  }
}

void Reading () {
 context = new SimpleOpenNI(this);
  if(context.enableDepth() == false)
  {
     println("Can't open the depthMap, maybe the camera is not connected!"); 
     exit();
     return;
  }

    println("This file has " + context.framesPlayer() + " frames.");

}
void Recording(String name) {

  println("Recording Setup");
   // recording
    // enable depthMap generation 
    context.enableDepth();

    // enable ir generation
 //   context.enableRGB();

    // setup the recording 
    context.enableRecorder(name+".oni");

    // select the recording channels
    context.addNodeToRecording(SimpleOpenNI.NODE_DEPTH,true);
   // context.addNodeToRecording(SimpleOpenNI.NODE_IMAGE,false);
}

Thanks,

Florian

Sign In or Register to comment.