I'm running Processing 2.2.1 along with SimpleOpenNI 1.96 (based on instructions at http://shiffman.net/p5/kinect/). I modified the DepthImage example sketch and added file writing (code below).
I'm trying to output the depth data from Kinect to .txt files in a folder of my choice. In the Processing IDE, the sketch runs fine; the depth is output-ed to the files correctly.
However I would like this functionality in an .exe file so that another program can run this .exe and read from those files, at run time. Export functionality in Processing IDE runs without errors and I get both win32 and win64 application folder. But if I execute .exe present in either one of them, nothing happens; I cannot see any errors anywhere. Even if I select "Present Mode" while exporting, only a gray screen appears but I cannot see any files being written to the path I supply. Toggle various selections (PresentMode/Export java) on the Export options windows hasn't helped.
Following is my sketch that works correctly in the IDE:
import SimpleOpenNI.*;
SimpleOpenNI context;
int[] dmap;
int dsize;
float[] dmapf;
PrintWriter output;
int fitr;
String path;
void setup()
{
size(640*2, 480);
fitr=1;
context = new SimpleOpenNI(this);
if (context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
// mirror is by default enabled
context.setMirror(false);
// enable depthMap generation
context.enableDepth();
// enable ir generation
context.enableRGB();
path = savePath("E:\\SYMMBOT\\DepthReading");
}
void draw()
{
// update the cam
context.update();
dmap = context.depthMap();
//dmapf = dmap.array();
output = createWriter(path+"\\depth"+fitr+".txt");
fitr++;
int itr = 0;
for(int i=0; i<480; i++){
for(int j=0;j<640;j++){
output.print(dmap[itr]+" ");
itr++;
}
output.println();
}
output.flush();
output.close();
//dsize = context.depthMapSize();
background(200, 0, 0); //<>//
// draw depthImageMap
image(context.depthImage(), 0, 0);
// draw irImageMap
image(context.rgbImage(), context.depthWidth() + 10, 0);
}
I tried using savePath() function because someone tried it on another forum (but that was not for a kinect application). But no change - it only works if I run it from the Processing IDE, not using the .exe. Any suggestions would be appreciated.