我想在我的android studio项目中写一个PCD文件(我有一个Project Tango)。
我该怎么做?
在我写的清单中:
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
但我需要知道如何在javas活动中编写* .pcd。
有人可以帮助我吗?
答案 0 :(得分:0)
AndroidManifest.xml文件
//Permissions should be:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
编写* .PCD文件的代码
//Write to the sdcard in folder Documents:
out = new BufferedWriter(new FileWriter(new File(new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS), filename));
//Write the header:
out.write(".PCD v.7 - Point Cloud Data file format\n" +
"VERSION .7\n" +
"FIELDS x y z\n" +
"SIZE 4 4 4\n" + //you only have 3 values xyz
"TYPE F F F\n" +
"COUNT 1 1 1\n" +
"WIDTH "+ xyzIj.xyzCount "\n" +
"HEIGHT 1\n" +
"VIEWPOINT 0 0 0 1 0 0 0\n" +
"POINTS " + xyzIj.xyzCount + "\n"
"DATA ascii \n");
//Write the point cloud points by iterating over the XYZij buffer:
for (int i=0; i<=xyzIj.xyz.length-3; i+=3) {
out.write(String.valueOf(xyzIj.xyz[i]) + " "); // separate the float values
out.write(String.valueOf(xyzIj.xyz[i+1]) + " ");
out.write(String.valueOf(xyzIj.xyz[i+2]) + "\n");
}
out.close();