简体   繁体   中英

How can I write a PCD file from Android Studio?

I want to write a PCD file in my android studio project (I have a Project Tango).

How can I do that?

In the manifest I wrote:

uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 

but I need to know how to write a *.pcd in the javas activity.

Can someone help me?

AndroidManifest.xml file

//Permissions should be:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Code to write a *.PCD file

//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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM