我将处理与 kinect 结合使用来捕获点云数据。我的草图将点的矢量位置从 kinect 写入数组,并使用 PrintWriter 类创建文本文件,将每个帧中的所有点存储在单独的文本文件中。它包括一个条件,应该阻止打印作者写作,但它继续写,并最终挂断。关于什么可能是错的任何想法?这是我的代码:
录制时:
PVector realWorldPoint; //stores each point as a vector
PVector[] frame = new PVector[arrayLength]; //stores all of the vectors/real world points in an array
int index = 0;
for(int y=0;y < context.depthHeight();y+=steps) //height = 480
{
for(int x=0;x < context.depthWidth();x+=steps) //width = 640
{
if (isRecording == true){
int offset = x + y * context.depthWidth();
realWorldPoint = context.depthMapRealWorld()[offset];
frame[index] = realWorldPoint;
recording.add(frame);
index++;
}
}
}
和保存时:
if (isRecording == true){
isRecording = false;
println("Stopped Recording");
Enumeration e = recording.elements();
int i = 0;
while (e.hasMoreElements()) {
// Create one directory
boolean success = (new File("out"+currentFile)).mkdir();
PrintWriter output = createWriter("out"+currentFile+"/frame" + i++ +".txt");
PVector [] frame = (PVector []) e.nextElement();
for (int j = 0; j < frame.length; j++) {
output.println(j + ", " + frame[j].x + ", " + frame[j].y + ", " + frame[j].z );
}
output.flush(); // Write the remaining data
output.close(); //Doesn't seem to close
}
println("done recording"); //NEVER EXECUTES
}
这些是大文件(每条大约 12,000 行),我每秒创建大约 30 个。也许它只是超载它所以停止永远不会注册?另外,不确定枚举 - 这是从其他人的代码中复制的,但我没有看到有关此数据类型的文档。