@Override public void onSnapshotTaken(byte[] pictureData, Snapshot snapshot) { // a snapshot has just been taken : float pitch = snapshot.getPitch(); float yaw = snapshot.getYaw(); if (!removeMarker(pitch, yaw) || !removeContour(pitch, yaw)) { Log.e(TAG, "cannot remove mark for snapshot (p=" + pitch + ", y=" + yaw + ")"); } // put a new textureSurface with the snapshot in it. putSnapshot(pictureData, snapshot); }
/** * Remove the dot near the given position. * * @param pitch * @param yaw */ private boolean removeMarker(float pitch, float yaw) { final float TRESHOLD = 10.0f; Snapshot o = new Snapshot(pitch, yaw); mTargetsLock.lock(); for (Snapshot3D dot : mDots) { if (o.getDistance(dot) < TRESHOLD) { mDots.remove(dot); mTargetsLock.unlock(); return true; } } mTargetsLock.unlock(); return false; }
/** * Remove the dot near the given position. * * @param pitch * @param yaw */ private boolean removeContour(float pitch, float yaw) { final float TRESHOLD = 10.0f; Snapshot o = new Snapshot(pitch, yaw); int i = 0; mTargetsLock.lock(); for (Snapshot3D contour : mContours) { if (o.getDistance(contour) < TRESHOLD) { mContours43.remove(i); mContours34.remove(i); mTargetsLock.unlock(); return true; } ++i; } mTargetsLock.unlock(); return false; }
/** * get distance between current orientation and gven snapshot * * @param snapshot * @return */ private float getSnapshotDisnance(EulerAngles a) { Snapshot s = new Snapshot(super.getPitch(), super.getYaw()); return s.getDistance(a); }