apriltag

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 4 Imported by: 0

README

go-apriltag

GoDoc Reference Coverage Status Go Report Card

Description

Apriltags image recognition for Go.

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

Installation

This package can be installed with the go get command:

go get github.com/twitchyliquid64/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/twitchyliquid64/go-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

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

Index

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