/accurate-aprilgroup-tracking

Using AprilTags to estimate the pose of a DodecaPen. Optical flow and dense pose alignment algorithms are used to improve pose accuracy. One of the outcomes will be to track the object and obtain a drawing using the DodecaPen.

Primary LanguagePython

Accurate AprilGroup Tracking

Accurate AprilGroup Tracking

Table of Contents

Accurate AprilGroup Tracking Milestones

High Level Goals

Improve the accuracy and tracking of apriltags over typical pose estimation techniques. Algorithms that have shown promising results in this area, such as the ones found in this paper (video demonstration, website) will be implemented. By doing so, an understanding of pose estimation, optical flow and non-linear least squares, among others, will be gained.

To get a breakdown of the milestones for this project, click here!

Usage

Requirements

Software

This project was implemented and tested on Ubuntu. For this project, you will need:

Hardware

You will need:

Project Installation

Step 1
To clone and run this application, you'll need Git installed on your computer. From your command line:

# Clone this repository 
git clone https://github.com/Virtana/accurate-aprilgroup-tracking.git

# Go into the repository
cd accurate-aprilgroup-tracking

Step 2
Set Up Programming Environment [If you already have this setup, you can skip this.]

  • Update and Upgrade
$ sudo apt update
$ sudo apt -y upgrade
  • Check your python version
$ python3 -V
  • Install pip
$ sudo apt install -y python3-pip

Step 3 [Optional]
Create new Python virtual environment [Optional but best practice]

  • To get the commands to create your virtual environment on Ubuntu, click here.

Step 4
Install the necessary libraries:

# At root directory, run
$ pip3 install -r requirements.txt

If you are using the Python virtual environment, activate it and the run the above command.

Step 4
Install OpenCV and the AprilTag library

If you are using the Python virtual environment, link these libraries to the environment:

cd ~/venv/lib/python3.[your python3 version number]/site-packages/
# Linking OpenCV library
ln -s /usr/lib/python3/dist-packages/cv2.cpython-38-x86_64-linux-gnu.so cv2.so
# Linking AprilTag library
ln -s /usr/local/lib/libapriltag.so

These were the locations the libraries downloaded for me, but they typically download under /usr/local/lib/python3.[your python3 version number].

See here for more details regarding OpenCV library. After linking, add the apriltag.py file obtained from installation, to the same directory: venv/lib/python3.8/site-packages/

Step 5
Execute the program

  • Take images of your chessboard with your USB camera
  • Create a folder named "images" under the directory: aprilgroup_tracking/calibration/
  • Store your images under this folder
  • Obtain the Calibrated Dodecahedron and it's information (measured tag sizes, rotation and translation vectors) as a .json file
  • Store this .json file under the directory: aprilgroup_tracking/aprilgroup_pose_estimation/april_group.json
  • Calibrate, Detect and Estimate the pose of the Dodecahedron by running:
Bash Options Argument Description
---disable-enhanced-ape - No enhancement on APE would be completed, meaning that cv:solvePnP() would be called with no extrinsic guesses. The default is set to True.
  • Calibrate, Detect and Estimate the pose of the Dodecahedron by running:
# Assumming you are in the directory: accurate-aprilgroup-tracking
# The following command line arguements are used on the terminal:

# An example:
$ python3 aprilgroup_tracking/main.py --disable-enhanced-ape

This will search for the camera intrinsic parameters, if found, it will store them, if not found, it will run the calibration using the images you took. After calibration, two windows will open up. Move your calibrated dodecahedron in front of your camera, or vice versa. The pose points will be overlaid onto your dodecahedron, and the pose drawing will be displayed on the other window. Any logs created would be stored under the logs folder.

N.B: More details and patches coming soon...