com.google.atap.tangoservice.TangoXyzIjData Java Examples
The following examples show how to use
com.google.atap.tangoservice.TangoXyzIjData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From tango-ar-navigation-example with MIT License | 4 votes |
@Override public void onXyzIjAvailable(TangoXyzIjData xyzIj) { if (tangoUx != null) { tangoUx.updateXyzCount(xyzIj.xyzCount); } }
Example #2
Source File: PointCloudActivity.java From tango with MIT License | 4 votes |
private void saveScanData(TangoPoseData pose, final TangoXyzIjData xyzIj) throws IOException { saveScan = false; Log.i(TAG, "Saving"); if (!isExternalStorageWritable()) { Log.e(TAG, "External storage unavailable"); return; } File dir = getScanStorageDir(); if (dir == null) { Log.e(TAG, "Failed to create scan directory"); return; } String filename = String.format("Scan%05d.data", scanNumber); scanNumber += 1; File file = new File(dir, filename); Log.i(TAG, "Writing data to "+file.getAbsolutePath()); // Set up buffers BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); ByteBuffer buf = ByteBuffer.allocate(4*8); buf.order(ByteOrder.LITTLE_ENDIAN); // Write translation for (int i=0; i<pose.translation.length; i++) { buf.putDouble(pose.translation[i]); } out.write(buf.array(), 0, 3*8); // Write Rotation buf.clear(); for (int i=0; i<pose.rotation.length; i++) { buf.putDouble(pose.rotation[i]); } out.write(buf.array(), 0, 4 * 8); // Write field of view TangoCameraIntrinsics intrinsics = mTango.getCameraIntrinsics(TangoCameraIntrinsics.TANGO_CAMERA_COLOR); double vFOV = 2*Math.atan(0.5*intrinsics.height/intrinsics.fy); double hFOV = 2*Math.atan(0.5*intrinsics.width/intrinsics.fx); buf.clear(); buf.putDouble(hFOV); buf.putDouble(vFOV); out.write(buf.array(), 0, 16); // Write points buf.clear(); buf.putInt(xyzIj.xyzCount); out.write(buf.array(), 0, 4); Log.i(TAG, "xyzCount="+Integer.toString(xyzIj.xyzCount)); for (int i=0; i<10; i++) { Log.i(TAG, Float.toString(xyzIj.xyz.get(i*3))+", "+Float.toString(xyzIj.xyz.get(i*3+1))+", "+Float.toString(xyzIj.xyz.get(i*3+2))); } for (int i=0; i<xyzIj.xyzCount*3; i++) { buf.clear(); buf.putFloat(xyzIj.xyz.get(i)); out.write(buf.array(), 0, 4); } // Write IJ (Not yet implemented in Tango) buf.clear(); int ijCount = xyzIj.ijRows*xyzIj.ijCols; Log.i(TAG, "IJCount="+Integer.toString(ijCount)); Log.i(TAG, "ijRows="+Integer.toString(xyzIj.ijRows)+" ijCols="+Integer.toString(xyzIj.ijCols)); ijCount=0; buf.putInt(ijCount); out.write(buf.array(), 0, 4); // if (ijCount>0) { // byte[] ijBuffer = new byte[ijCount * 4]; // FileInputStream ijStream = new FileInputStream( // xyzIj.ijParcelFileDescriptor.getFileDescriptor()); // try { // ijStream.read(ijBuffer, 0, ijCount * 4); // ijStream.close(); // } catch (IOException e) { // e.printStackTrace(); // } // out.write(ijBuffer); // } out.close(); MediaScannerConnection.scanFile( getApplicationContext(), new String[] {file.getAbsolutePath()}, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { Log.v(TAG, "file " + path + " was scanned successfully: " + uri); } }); Log.i(TAG, "Done"); }