For 3D tracking, ImageDetectionFilter
needs all the same member variables as before, except the mSceneCorners
variable. We also need several new variables 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 { // ... // The reference image's corner coordinates, in 3D, in real // units. private final MatOfPoint3f mReferenceCorners3D = new MatOfPoint3f(); // Good corner coordinates detected in the scene, in // pixels. private final MatOfPoint2f mSceneCorners2D = new MatOfPoint2f(); // Distortion coefficients of the camera's lens. // Assume no distortion. private final MatOfDouble mDistCoeffs = new MatOfDouble(0.0, 0.0, 0.0, 0.0); // An adaptor that provides the camera's projection matrix. private final CameraProjectionAdapter mCameraProjectionAdapter; ...