project

package
v0.0.0-...-9dd255e Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: CC-BY-4.0, MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const SkipRotate = 0.00001

Variables

View Source
var Template *template.Template

Functions

func ConfigureUI

func ConfigureUI(p *Project, httpAddress string)

exposes a UI for configuration and exits on save or cancel

func OpenInBrowser

func OpenInBrowser(l net.Listener) error

func Radians

func Radians(a, b Point) float64

func RadiansToDegrees

func RadiansToDegrees(rad float64) (deg float64)

Types

type Analyzer

type Analyzer struct {
	Background        *image.RGBA
	BWCutoff          uint8
	BlurRadius        int
	ContinguousPixels int
	MinMass           int
}

func (Analyzer) Positions

func (a Analyzer) Positions(src *image.RGBA) []labelimg.Label

type BBox

type BBox struct {
	A Point `json:"a"`
	B Point `json:"b"`
}

func ParseBBox

func ParseBBox(s string) (b *BBox)

func (BBox) Dx

func (b BBox) Dx() int

func (BBox) Dy

func (b BBox) Dy() int

func (BBox) Height

func (b BBox) Height() float64

func (*BBox) IsZero

func (b *BBox) IsZero() bool

func (BBox) Rect

func (b BBox) Rect() image.Rectangle

func (*BBox) String

func (b *BBox) String() string

func (BBox) Width

func (b BBox) Width() float64

type Calibration

type Calibration struct {
	Seek   float64 `json:"seek"`
	A      Point   `json:"a"`
	B      Point   `json:"b"`
	Inches float64 `json:"inches"`
}

func ParseCalibration

func ParseCalibration(s string) (c *Calibration)

func (*Calibration) Pretty

func (c *Calibration) Pretty() string

func (*Calibration) String

func (c *Calibration) String() string

type FrameAnalysis

type FrameAnalysis struct {
	Timestamp time.Duration `json:"ts"`

	Base         template.URL `json:"base,omitempty"` // first frame
	BaseGif      template.URL `json:"base_gif,omitempty"`
	Highlight    template.URL `json:"highlight,omitempty"` // frame - bg
	HighlightGif template.URL `json:"highlight_gif,omitempty"`
	Colored      template.URL `json:"colored,omitempty"` // detected items in highlight
	ColoredGif   template.URL `json:"colored_gif,omitempty"`

	Positions []labelimg.Label `json:"positions,omitempty"`
	// contains filtered or unexported fields
}

func (*FrameAnalysis) Calculate

func (f *FrameAnalysis) Calculate(bg *image.RGBA, blurRadius, contiguousPixels, minMass int, tolerance uint8)

func (FrameAnalysis) NeedsMore

func (f FrameAnalysis) NeedsMore() bool

type FramePosition

type FramePosition struct {
	Frame     int
	Time      time.Duration
	Positions []labelimg.Label
}

type Iterator

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

func NewIterator

func NewIterator(filename string) (iter *Iterator, err error)

func (*Iterator) Close

func (p *Iterator) Close()

func (*Iterator) Duration

func (i *Iterator) Duration() time.Duration

func (*Iterator) DurationMs

func (i *Iterator) DurationMs() time.Duration

func (*Iterator) Error

func (i *Iterator) Error() error

func (*Iterator) Frame

func (i *Iterator) Frame() int

func (*Iterator) Image

func (i *Iterator) Image() image.Image

func (*Iterator) IsKeyFrame

func (i *Iterator) IsKeyFrame() bool

func (*Iterator) Next

func (i *Iterator) Next() bool

func (*Iterator) Seek

func (i *Iterator) Seek(d time.Duration) error

func (*Iterator) VideoResolution

func (i *Iterator) VideoResolution() string

type Mask

type Mask struct {
	Start    int64 `json:"start,omitempty"`
	End      int64 `json:"end,omitempty"`
	BBox     *BBox `json:"bbox,omitempty"`
	NullMask bool  `json:"null_mask,omitempty"`
}

func ParseMask

func ParseMask(s string) (m Mask, ok bool)

func (Mask) String

func (m Mask) String() string

type Masks

type Masks []Mask

func (Masks) Apply

func (m Masks) Apply(i image.Image)

func (Masks) Uniq

func (m Masks) Uniq() Masks

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

func ParsePoint

func ParsePoint(s string) (p Point)

func (Point) String

func (p Point) String() string

type Position

type Position struct {
	X     float64 `json:"x"`
	Y     float64 `json:"y"`
	Mass  int     `json:"mass"`
	XSpan []int   `json:"xspan"` // [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
	YSpan []int   `json:"yspan"`
}

Position matches Position in position.jl

func (Position) Size

func (p Position) Size() string

func (Position) Span

func (p Position) Span() string

type Project

type Project struct {
	Filename string `json:"filename"` // Filename is not relative to Dir
	Dir      string `json:"dir,omitempty"`
	Settings `json:"settings"`

	Duration        time.Duration `json:"duration,omitempty"`
	VideoResolution string        `json:"video_resolution,omitempty"`
	Frames          int64         `json:"frames,omitempty"`

	Seek     float64  `json:"-"`
	Step     int      `json:"-"`
	Response Response `json:"-"`

	Err error `json:"-"`
}

func LoadProject

func LoadProject(f string) (*Project, error)

LoadProject loads a project from a JSON file

func NewProject

func NewProject(f string, iterator *Iterator) *Project

NewProject starst a project for the specified video file

func (*Project) Iterator

func (p *Project) Iterator() (*Iterator, error)

func (*Project) Load

func (p *Project) Load(req *http.Request) error

func (*Project) Run

func (p *Project) Run() (Response, error)

func (*Project) SaveImage

func (p *Project) SaveImage(i image.Image, name string) error

func (*Project) SetStep

func (p *Project) SetStep()

type Response

type Response struct {
	PreCroppedResolution string          `json:"pre_cropped_resolution,omitempty"`
	CroppedResolution    string          `json:"cropped_resolution,omitempty"`
	OverviewGif          template.URL    `json:"overview_gif,omitempty"`
	Step4Img             template.URL    `json:"step_4_img,omitempty"` // mask
	Step4MaskImg         template.URL    `json:"step_4_mask_img,omitempty"`
	BackgroundImg        template.URL    `json:"background_img,omitempty"`
	FrameAnalysis        []FrameAnalysis `json:"frame_analysis,omitempty"`
	VehiclePositions     []VehiclePosition
	Step6Img             template.URL `json:"step_6_img,omitempty"`

	DebugImages []template.URL
}

type Settings

type Settings struct {
	PreCrop          *BBox          `json:"pre_crop,omitempty"`
	Rotate           float64        `json:"rotate,omitempty"` // radians
	PostCrop         *BBox          `json:"post_crop,omitempty"`
	Masks            Masks          `json:"masks,omitempty"`
	Tolerance        uint8          `json:"tolerance,omitempty"`
	Blur             int            `json:"blur,omitempty"`
	ContiguousPixels int            `json:"contiguous_pixels,omitempty"`
	MinMass          int            `json:"min_mass,omitempty"`
	Calibrations     []*Calibration `json:"-"`
}

Settings are the user configurable options

type VehiclePosition

type VehiclePosition struct {
	Frame     int
	Time      time.Duration
	VehicleID int
	Position  labelimg.Label
}

func ClosestPosition

func ClosestPosition(point image.Point, v []VehiclePosition) VehiclePosition

func TrackVehicles

func TrackVehicles(frames []FramePosition) []VehiclePosition

TrackVehicles tracks detected objects and correlates across frames based on logic from identifyvehicles from https://github.com/mbauman/TrafficSpeed/blob/master/TrafficSpeed.ipynb

Jump to

Keyboard shortcuts

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