Skip to content

Instantly share code, notes, and snippets.

@danilogr
Created February 22, 2021 20:33
Show Gist options
  • Save danilogr/1f4768ec1acec9b8da918fbd20cfe608 to your computer and use it in GitHub Desktop.
Save danilogr/1f4768ec1acec9b8da918fbd20cfe608 to your computer and use it in GitHub Desktop.
Finding AprilTag markers in Mars! NASA's rover Perseverance uses AprilTags!
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Detecting and Locating NASA's Perseverance AprilTags"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**The goal of this Jupyter notebook is to detect and draw AprilTag markers from Mars :)**\n",
"\n",
"This task is trivial due to open source software such as OpenCV and aruco's implementation of AprilTags.\n",
"\n",
"I would love to detect their pose (location and orientation), but I don't have the camera intrinsic parameters. NASA is using a commercial camera, so it shouldn't be hard to find them.\n",
"\n",
"\n",
"(author: Danilo Gasques - [email protected])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Import OpenCV2, ARUCO, Matplotlib, and numpy"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import cv2\n",
"import cv2.aruco as arc # make sure that you installed opencv contrib\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"\n",
"# changes picture dimensions (the bigger the longer it takes to load)\n",
"plt.rcParams[\"figure.figsize\"] = (40,40)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load image and maker dictionary \n",
"You can download the original image here: https://mars.nasa.gov/resources/25618/navcam-panorama-of-the-perseverance-rovers-deck/"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(960, 1280)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# loads in black and white\n",
"img = cv2.imread('4_-_PIA24421_-_Deck_NLFC0002_0667125069_000FDR_N0010052AUT_04096_0A02I2J01-stretched.png', 0)\n",
"img.shape"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
@danilogr
Copy link
Author

It would be great to have the camera intrinsics for this panorama as well as the actual size (in meters) of the AprilTag markers.
With these, we would be able to find the location and orientation of the camera.

@woswos
Copy link

woswos commented Feb 22, 2021

I'm glad to see that someone else noticed these AprilTag markers, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment