We are going to implement our demo in a single script, ImageTrackingDemo.py, which will contain the following components:
- Import statements
- A helper function for a custom grayscale conversion
- Helper functions to convert keypoints from 2D to 3D space
- An application class, ImageTrackingDemo, which will encapsulate a model of the camera and lens, a model of the reference image, a Kalman filter, 6DOF tracking results, and an application loop that will track the image and draw a simple AR visualization
- A main function to launch the application
The script will depend on one other file, reference_image.png, which will represent the image that we want to track.
Without further ado, let's dive into the script's implementation.