Skip to content

Apriltag Vision

Renato Dell'Osso edited this page Aug 24, 2023 · 1 revision

Apriltag Vision

Setting Up the Apriltag Detector

We need parameters for the Apriltag detector in order to accurately detect tags.

Use the following parameters (tested on Microsoft LifeCam HD-3000)

at_detector = Detector(
   families="tag16h5",
   nthreads=1,
   quad_decimate=0.3,
   quad_sigma=0.35,
   refine_edges=1,
   decode_sharpening=0.25,
   debug=0
)

Recoloring

To detect Apriltags we must be in a grayscale color space.


imgGrayscale = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Checking For Apriltag

First we check for apriltags in the image, then we take only the apriltags that the program is most confident in seeing.

****`apriltags = at_detector.detect(imgGrayscale)

apriltags = [x for x in apriltags if x.hamming == 0]`

Locating Apriltag Positions

for i in range(len(apriltags)):
    centerXY = ast.literal_eval((re.sub(" +", " ", ((str(apriltags[i].center).replace("[", "")).replace("]", "")).strip())).replace(" ", ", "))
    centerXY = list(centerXY)
    centerXY[0] = centerXY[0] - 320
    centerXY[1] = centerXY[1] - 240

centerXY[0] is the X position of the Apriltag. centerXY[1] is the Y position of the Apriltag.

Finding Tag ID

for i in range(len(apriltags)):
		tagID = apriltags[i].tag_id

Clone this wiki locally