cvpipe

package module
v0.0.0-...-0f97af3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 4 Imported by: 0

README

cvpipe

cvpipe is a tool for quickly prototyping computer vision filters and operations using OpenCV/GoCV.

Getting Started

Build and run the docker image to quickly get started:

docker build -t cvpipe .
docker run -it --rm \
--mount type=bind,source="$(pwd)/data",target=/go/src/cvpipe/data \
-t cvpipe

Usage

The cvpipe package provides a simple API for chaining together OpenCV operations in Go. The following pseudo-code demonstrates the intention of the package:

pipe := NewPipe()
defer pipe.Close()

result := pipe.
    Add(ResizeOperation(0.5)).
    Add(BlurOperation(5)).
    Add(ThresholdOperation(127)).
    Run(image)
defer result.Close()

// Do something with the result

For up-to-date, working/running examples, see the cmd directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Name() string
	Apply(m *PipeMat) *PipeMat
	Close()
}

func NewAdaptiveThreshold

func NewAdaptiveThreshold(maxValue float32, adaptiveTyp gocv.AdaptiveThresholdType, typ gocv.ThresholdType, blockSize int, c float32) Filter

func NewCanny

func NewCanny(threshold1, threshold2 float32) Filter

func NewDilate

func NewDilate(shape gocv.MorphShape, ksize image.Point) Filter

func NewErode

func NewErode(shape gocv.MorphShape, ksize image.Point) Filter

func NewGaussianBlur

func NewGaussianBlur(ksize image.Point, sigmaX, sigmaY float64, typ gocv.BorderType) Filter

func NewLine

func NewLine(pt1, pt2 image.Point, color color.RGBA, thickness int) Filter

func NewMorphology

func NewMorphology(op gocv.MorphType, shape gocv.MorphShape, ksize image.Point) Filter

func NewPutText

func NewPutText(text string, org image.Point, fontFace gocv.HersheyFont, fontScale float64, color color.RGBA, thickness int) Filter

func NewRectangle

func NewRectangle(r image.Rectangle, c color.RGBA, thickness int) Filter

func NewResize

func NewResize(sz image.Point, fx, fy float64, interp gocv.InterpolationFlags) Filter

func NewSobel

func NewSobel(ddepth gocv.MatType, dx, dy, ksize int, scale, delta float64, typ gocv.BorderType) Filter

func NewThreshold

func NewThreshold(thresh, maxValue float32, typ gocv.ThresholdType) Filter

type FilterOptions

type FilterOptions struct {
	// Enable saving of this step's result. Takes precedence over Pipe options
	Save *bool
}

type MatOptions

type MatOptions struct {
	Size *image.Point
	Type *gocv.MatType
}

type Pipe

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

func NewPipe

func NewPipe(name string, opts PipeOptions) *Pipe

func (*Pipe) Add

func (p *Pipe) Add(f Filter, opts ...FilterOptions) *Pipe

Add a filter to the pipe. If save is true, the result of this step will be saved to disk.

func (*Pipe) Close

func (p *Pipe) Close()

func (*Pipe) Run

func (p *Pipe) Run(m *PipeMat) *PipeMat

Run applies all filters in the pipe to the given PipeMat.

type PipeMat

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

func NewPipeMat

func NewPipeMat(mat gocv.Mat) *PipeMat

func NewPipeMatFromOptions

func NewPipeMatFromOptions(opts MatOptions) (*PipeMat, error)

func (*PipeMat) Close

func (m *PipeMat) Close()

type PipeOptions

type PipeOptions struct {
	// Enable saving of intermediate results. Will be overridden by individual step save options.
	Save bool
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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