apriltag

package module
v0.0.0-...-beb1a6e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2021 License: MIT Imports: 4 Imported by: 0

README

apriltag

Description

Apriltags image recognition for Go.

Uses Cgo, but does not require any libraries or dependencies.

This is a fork of go get github.com/twitchyliquid64/go-apriltag that fixes a few bugs and adds a tutorial.

Installation

This package can be installed with the go get command:

go get github.com/koeng101/go-apriltag

NOTE: Make sure cgo works on your system.

Only tested on Linux, but should work (or need trivial modifications) to work on other platforms.

Documentation

API documentation can be found here: http://godoc.org/github.com/koeng101/apriltag

Trivial example, finding apriltags in a PNG:

detector := apriltag.New()
defer detector.Close()
f, err := os.Open("testtags.png")
if err != nil {
  t.Fatal(err)
}
defer f.Close()

img, err := png.Decode(f)
if err != nil {
  t.Fatal(err)
}

findings := detector.Find(ImgToGrayscale(img)) // list of discovered tags

// If you want you can draw boxes around the tags
center := color.RGBA{R: 255, G: 0, B: 0, A: 255}
corner := color.RGBA{R: 0, G: 255, B: 0, A: 255}
apriltag.DrawFindings(img.(*image.RGBA), findings, center, corner)

Example output

Bug Fixes

  • In common/image_f32.c the variable HUGE was undeclared. This code is never actually used, so I just deleted it.
  • -fno-strict-overflow wasn't required and removal let you do a classic go test for testing purposes.

License

In this repository, those files are an amalgamation of code that was copied from Apriltag. The license of that code is the same as the license of Apriltag. Apriltag copyright notices remain intact as per license requirements.

For all non-Apriltag code, consider the license text as per the LICENSE file.

Documentation

Overview

Example (Basic)
package main

import (
	"fmt"
	"github.com/koeng101/apriltag"
	"image/png"
	"os"
)

func main() {
	detector := apriltag.New()
	f, _ := os.Open("testtags.png")

	img, _ := png.Decode(f)
	findings := detector.Find(apriltag.ImgToGrayscale(img))

	fmt.Println(findings[0].Corners)
}
Output:

[[3.874999999998289 88.91883850097827] [83.87499999999712 88.8625869750948] [83.87500000000203 9.199375152585876] [3.8750000000025526 8.799375534060175]]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawFindings

func DrawFindings(img WritableImage, findings []Finding, centerColor, cornerColor color.Color)

DrawFindings draws all found apriltags on the provided image.

func ImgToGrayscale

func ImgToGrayscale(img image.Image) *image.Gray

ImgToGrayscale converts a image.Image into an image.Gray

Types

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector encapsulates an apriltag detector initialized with a tag family.

func New

func New() *Detector

New creates a new 36h11 detector.

func (*Detector) Close

func (d *Detector) Close() error

Close frees the underlying resources of the detector.

func (*Detector) Find

func (d *Detector) Find(goImage *image.Gray) []Finding

Find returns a slice of all the apriltags found in the provided image.

type Finding

type Finding struct {
	// The decoded ID of the tag
	ID int

	// The number of error bits that were corrected.
	Hamming  int
	Goodness float32
	// A measure of the quality of the binary decoding process. Higher == better.
	DecisionMargin float32

	// Centeroid of the detected tag
	CenterX float64
	CenterY float64
	// Bounding edges of the detected tag. [0] = X, [1] = Y.
	Corners [4][2]float64
}

Finding represents a single apriltag detected in an image.

type WritableImage

type WritableImage interface {
	image.Image
	Set(x, y int, c color.Color)
}

WritableImage represents a drawing surface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL