private boolean isARCoreSupported(Context context) { // Make sure ARCore is installed and available on the device. return Session.isSupported(context); }
private Session mSession; // Class field. ... mSession = new Session(/* context = */ this);
... Frame frame = mSession.update(); if (frame != null) { try (PointCloud pointCloud = frame.acquirePointCloud()) { // Get all the points in the point cloud. FloatBuffer pointCloudBuffer = pointCloud.getPoints(); for (int i = 0; i < pointCloudBuffer.capacity(); i += 4) { float x = pointCloudBuffer.get(i); float y = pointCloudBuffer.get(i+1); float z = pointCloudBuffer.get(i+2); // Do something with the x, y, z 3D coordinates. } } }