stitch

package
v0.0.0-...-51c8454 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package stitch allows stitching a sequence of image frames of a linearly (as in direction) moving object into an image of the entire object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoStitcher

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

AutoStitcher is an automatic train detector and stitcher. Use NewAutoStitcher() to create an instance.

func NewAutoStitcher

func NewAutoStitcher(c Config) *AutoStitcher

NewAutoStitcher creates a new AutoStitcher.

func (*AutoStitcher) Frame

func (r *AutoStitcher) Frame(frameColor image.Image, ts time.Time) *Train

Frame adds a frame to the AutoStitcher. Takes ownership of the image data buffer, so be sure to make a copy before passing it.

func (*AutoStitcher) TryStitchAndReset

func (r *AutoStitcher) TryStitchAndReset() *Train

TryStitchAndReset tries to stitch any remaining frames and resets the sequence.

type Config

type Config struct {
	PixelsPerM  float64
	MinSpeedKPH float64
	MaxSpeedKPH float64
	MinLengthM  float64
}

Config is the configuration for a AutoStitcher. All values must be > 0, except for MinSpeedKPH which might also be 0.

type Train

type Train struct {
	StartTS time.Time

	// Always positive.
	NFrames int

	// Always positive (absolute value).
	LengthPx float64
	// Positive sign means movement to the right, negative to the left.
	SpeedPxS float64
	// Positive sign means increasing speed for trains going to the right, breaking for trains going to the left.
	AccelPxS2 float64

	Conf Config

	Image *image.RGBA `json:"-"`
	GIF   *gif.GIF    `json:"-"`
}

Train represents a detected train.

func (*Train) AccelMpS2

func (t *Train) AccelMpS2() float64

AccelMpS2 returns the acceleration in m/2^2, corrected for speed direction: Positive means accelerating, negative means breaking.

func (*Train) Direction

func (t *Train) Direction() bool

Direction returns the train direction. Right = true, left = false.

func (*Train) DirectionS

func (t *Train) DirectionS() string

DirectionS returns the train direction as string "left" or "right".

func (*Train) LengthM

func (t *Train) LengthM() float64

LengthM returns the absolute length in m.

func (*Train) SpeedMpS

func (t *Train) SpeedMpS() float64

SpeedMpS returns the absolute speed in m/s.

Jump to

Keyboard shortcuts

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