O'Reilly logo

Android Application Programming with OpenCV by Joseph Howse

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modifying ImageDetectionFilter for 3D tracking

For 3D tracking, ImageDetectionFilter needs all the same member variables as before, plus several more to store computations about the target's pose. Moreover, the class needs to implement the ARFilter interface. Let's modify ImageDetectionFilter as follows:

public class ImageDetectionFilter implements ARFilter {

  // ...

  private final MatOfDouble mDistCoeffs = new MatOfDouble(
    0.0, 0.0, 0.0, 0.0);

  private final CameraProjectionAdapter mCameraProjectionAdapter;
  private final MatOfDouble mRVec = new MatOfDouble();
  private final MatOfDouble mTVec = new MatOfDouble();
  private final MatOfDouble mRotation = new MatOfDouble();
  private final float[] mGLPose = new float[16];

  private boolean mTargetFound = false; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required