contrib

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Using OpenCV Contrib

The OpenCV Contrib library contains experimental or non-free (aka patented) algorithms.

GoCV support for OpenCV Contrib can be found here in the "gocv.io/x/gocv/contrib" package.

For more information about OpenCV Contrib, please go to:

https://github.com/opencv/opencv_contrib

How to use

If you have followed the installation instructions from the main README, then the OpenCV contrib modules have already been compiled and installed.

First, you must include the contrib subpackage:

import (
    "gocv.io/x/gocv"
    "gocv.io/x/gocv/contrib"
)

Then you will be able to use the functions within the contrib subpackage. For example, this uses the SIFT feature identitification algorithm that is within the xfeatures2d module of OpenCV:

si := contrib.NewSIFT()
kp := si.Detect(img)

Documentation

Overview

Package contrib is the GoCV wrapper around OpenCV Contrib.

For further details, please see: https://github.com/opencv/opencv_contrib

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AverageHash added in v0.16.0

type AverageHash struct{}

AverageHash is implementation of the AverageHash algorithm.

func (AverageHash) Compare added in v0.16.0

func (hash AverageHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using AverageHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (AverageHash) Compute added in v0.16.0

func (hash AverageHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using AverageHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type BlockMeanHash added in v0.16.0

type BlockMeanHash struct {
	Mode BlockMeanHashMode
}

BlockMeanHash is implementation of the BlockMeanHash algorithm.

func (BlockMeanHash) Compare added in v0.16.0

func (hash BlockMeanHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using BlockMeanHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (BlockMeanHash) Compute added in v0.16.0

func (hash BlockMeanHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using BlockMeanHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type BlockMeanHashMode added in v0.16.0

type BlockMeanHashMode int
const (
	BlockMeanHashMode0 BlockMeanHashMode = iota
	BlockMeanHashMode1
	BlockMeanHashModeDefault = BlockMeanHashMode0
)

type ColorMomentHash added in v0.16.0

type ColorMomentHash struct{}

ColorMomentHash is implementation of the ColorMomentHash algorithm.

func (ColorMomentHash) Compare added in v0.16.0

func (hash ColorMomentHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using ColorMomentHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (ColorMomentHash) Compute added in v0.16.0

func (hash ColorMomentHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using ColorMomentHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type ImgHashBase added in v0.16.0

type ImgHashBase interface {
	Compare(a, b gocv.Mat) float64
	Compute(inputArr gocv.Mat, outputArr *gocv.Mat)
}

ImgHashBase defines the interface used for all of the img_hash algorithms.

type LBPHFaceRecognizer

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

LBPHFaceRecognizer is a wrapper for the OpenCV Local Binary Patterns Histograms face recognizer.

func NewLBPHFaceRecognizer

func NewLBPHFaceRecognizer() *LBPHFaceRecognizer

NewLBPHFaceRecognizer creates a new LBPH Recognizer model.

For further information, see: https://docs.opencv.org/master/df/d25/classcv_1_1face_1_1LBPHFaceRecognizer.html

func (*LBPHFaceRecognizer) GetNeighbors

func (fr *LBPHFaceRecognizer) GetNeighbors() int

GetNeighbors returns the neighbors value of the model.

For further information, see: https://docs.opencv.org/master/df/d25/classcv_1_1face_1_1LBPHFaceRecognizer.html#a50a3e2ca6e8464166e153c9df84b0a77

func (*LBPHFaceRecognizer) LoadFile

func (fr *LBPHFaceRecognizer) LoadFile(fname string)

LoadFile loads a trained model data from file.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#acc42e5b04595dba71f0777c7179af8c3

func (*LBPHFaceRecognizer) Predict

func (fr *LBPHFaceRecognizer) Predict(sample gocv.Mat) int

Predict predicts a label for a given input image. It returns the label for correctly predicted image or -1 if not found.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#aa2d2f02faffab1bf01317ae6502fb631

func (*LBPHFaceRecognizer) PredictExtendedResponse

func (fr *LBPHFaceRecognizer) PredictExtendedResponse(sample gocv.Mat) PredictResponse

PredictExtendedResponse returns a label and associated confidence (e.g. distance) for a given input image. It is the extended version of `Predict()`.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#ab0d593e53ebd9a0f350c989fcac7f251

func (*LBPHFaceRecognizer) SaveFile

func (fr *LBPHFaceRecognizer) SaveFile(fname string)

SaveFile saves the trained model data to file.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#a2adf2d555550194244b05c91fefcb4d6

func (*LBPHFaceRecognizer) SetNeighbors

func (fr *LBPHFaceRecognizer) SetNeighbors(neighbors int)

SetNeighbors sets the neighbors value of the model, i.e. the number of sample points to build a Circular Local Binary Pattern from. Note that wrong neighbors can raise OpenCV exception!

For further information, see: https://docs.opencv.org/master/df/d25/classcv_1_1face_1_1LBPHFaceRecognizer.html#ab225f7bf353ce8697a506eda10124a92

func (*LBPHFaceRecognizer) SetRadius

func (fr *LBPHFaceRecognizer) SetRadius(radius int)

SetRadius sets the radius used for building the Circular Local Binary Pattern.

For further information, see: https://docs.opencv.org/master/df/d25/classcv_1_1face_1_1LBPHFaceRecognizer.html#a62d94c75cade902fd3b487b1ef9883fc

func (*LBPHFaceRecognizer) SetThreshold

func (fr *LBPHFaceRecognizer) SetThreshold(threshold float32)

SetThreshold sets the threshold value of the model, i.e. the threshold applied in the prediction.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#a3182081e5f8023e658ad8ab96656dd63

func (*LBPHFaceRecognizer) Train

func (fr *LBPHFaceRecognizer) Train(images []gocv.Mat, labels []int)

Train loaded model with images and their labels

see https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#ac8680c2aa9649ad3f55e27761165c0d6

func (*LBPHFaceRecognizer) Update

func (fr *LBPHFaceRecognizer) Update(newImages []gocv.Mat, newLabels []int)

Update updates the existing trained model with new images and labels.

For further information, see: https://docs.opencv.org/master/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#a8a4e73ea878dcd0c235d0487189d25f3

type MarrHildrethHash added in v0.16.0

type MarrHildrethHash struct {
	Alpha float32
	Scale float32
}

MarrHildrethHash is implementation of the MarrHildrethHash algorithm.

func NewMarrHildrethHash added in v0.16.0

func NewMarrHildrethHash() MarrHildrethHash

func (MarrHildrethHash) Compare added in v0.16.0

func (hash MarrHildrethHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using MarrHildrethHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (MarrHildrethHash) Compute added in v0.16.0

func (hash MarrHildrethHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using MarrHildrethHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type PHash added in v0.16.0

type PHash struct{}

PHash is implementation of the PHash algorithm.

func (PHash) Compare added in v0.16.0

func (hash PHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using PHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (PHash) Compute added in v0.16.0

func (hash PHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using PHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type PredictResponse

type PredictResponse struct {
	Label      int32   `json:"label"`
	Confidence float32 `json:"confidence"`
}

PredictResponse represents a predicted label and associated confidence.

type RadialVarianceHash added in v0.16.0

type RadialVarianceHash struct {
	Sigma          float64
	NumOfAngleLine int
}

RadialVarianceHash is implementation of the RadialVarianceHash algorithm.

func NewRadialVarianceHash added in v0.16.0

func NewRadialVarianceHash() RadialVarianceHash

func (RadialVarianceHash) Compare added in v0.16.0

func (hash RadialVarianceHash) Compare(a, b gocv.Mat) float64

Compare compares the hash value between a and b using RadialVarianceHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#a444a3e9ec792cf029385809393f84ad5

func (RadialVarianceHash) Compute added in v0.16.0

func (hash RadialVarianceHash) Compute(input gocv.Mat, output *gocv.Mat)

Compute computes hash of the input image using RadialVarianceHash.

For further information, see: https://docs.opencv.org/master/de/d29/classcv_1_1img__hash_1_1ImgHashBase.html#ae2d9288db370089dfd8aab85d5e0b0f3

type SIFT

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

SIFT is a wrapper around the cv::SIFT algorithm. Due to being a patented algorithm you must set the OpenCV contrib build flag OPENCV_ENABLE_NONFREE=1 in order to use it.

func NewSIFT

func NewSIFT() SIFT

NewSIFT returns a new SIFT algorithm.

For further details, please see: https://docs.opencv.org/master/d5/d3c/classcv_1_1xfeatures2d_1_1SIFT.html

func (*SIFT) Close

func (d *SIFT) Close() error

Close SIFT.

func (*SIFT) Detect

func (d *SIFT) Detect(src gocv.Mat) []gocv.KeyPoint

Detect keypoints in an image using SIFT.

For further details, please see: https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887

func (*SIFT) DetectAndCompute

func (d *SIFT) DetectAndCompute(src gocv.Mat, mask gocv.Mat) ([]gocv.KeyPoint, gocv.Mat)

DetectAndCompute detects and computes keypoints in an image using SIFT.

For further details, please see: https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677

type SURF

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

SURF is a wrapper around the cv::SURF algorithm. Due to being a patented algorithm you must set the OpenCV contrib build flag OPENCV_ENABLE_NONFREE=1 in order to use it.

func NewSURF

func NewSURF() SURF

NewSURF returns a new SURF algorithm.

For further details, please see: https://docs.opencv.org/master/d5/df7/classcv_1_1xfeatures2d_1_1SURF.html

func (*SURF) Close

func (d *SURF) Close() error

Close SURF.

func (*SURF) Detect

func (d *SURF) Detect(src gocv.Mat) []gocv.KeyPoint

Detect keypoints in an image using SURF.

For further details, please see: https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887

func (*SURF) DetectAndCompute

func (d *SURF) DetectAndCompute(src gocv.Mat, mask gocv.Mat) ([]gocv.KeyPoint, gocv.Mat)

DetectAndCompute detects and computes keypoints in an image using SURF.

For further details, please see: https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677

type Tracker added in v0.16.0

type Tracker interface {
	// Close closes, as Trackers need to be Closed manually.
	//
	Close() error

	// Init initializes the tracker with a known bounding box that surrounded the target.
	// Note: this can only be called once. If you lose the object, you have to Close() the instance,
	// create a new one, and call Init() on it again.
	//
	// see: https://docs.opencv.org/master/d0/d0a/classcv_1_1Tracker.html#a4d285747589b1bdd16d2e4f00c3255dc
	//
	Init(image gocv.Mat, boundingBox image.Rectangle) bool

	// Update updates the tracker, returns a new bounding box and a boolean determining whether the tracker lost the target.
	//
	// see: https://docs.opencv.org/master/d0/d0a/classcv_1_1Tracker.html#a549159bd0553e6a8de356f3866df1f18
	//
	Update(image gocv.Mat) (image.Rectangle, bool)
}

Tracker is the base interface for object tracking.

see: https://docs.opencv.org/master/d0/d0a/classcv_1_1Tracker.html

func NewTrackerBoosting added in v0.16.0

func NewTrackerBoosting() Tracker

NewTrackerBoosting returns a new TrackerBoosting.

func NewTrackerCSRT added in v0.16.0

func NewTrackerCSRT() Tracker

NewTrackerCSRT returns a new TrackerCSRT.

func NewTrackerKCF added in v0.16.0

func NewTrackerKCF() Tracker

NewTrackerKCF returns a new TrackerKCF.

func NewTrackerMIL added in v0.16.0

func NewTrackerMIL() Tracker

NewTrackerMIL returns a new TrackerMIL.

func NewTrackerMOSSE added in v0.16.0

func NewTrackerMOSSE() Tracker

NewTrackerMOSSE returns a new TrackerMOSSE.

func NewTrackerMedianFlow added in v0.16.0

func NewTrackerMedianFlow() Tracker

NewTrackerMedianFlow returns a new TrackerMedianFlow.

func NewTrackerTLD added in v0.16.0

func NewTrackerTLD() Tracker

NewTrackerTLD returns a new TrackerTLD.

type TrackerBoosting added in v0.16.0

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

TrackerBoosting is a real-time object tracker based on a novel on-line version of the AdaBoost algorithm.

For further details, please see: https://docs.opencv.org/master/d1/d1a/classcv_1_1TrackerBoosting.html

func (TrackerBoosting) Close added in v0.16.0

func (trk TrackerBoosting) Close() error

Close closes the TrackerBoosting.

func (TrackerBoosting) Init added in v0.16.0

func (trk TrackerBoosting) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes the Tracker.

func (TrackerBoosting) Update added in v0.16.0

func (trk TrackerBoosting) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates the Tracker.

type TrackerCSRT added in v0.16.0

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

TrackerCSRT is an implementation of Discriminative Correlation Filter Tracker with Channel and Spatial Reliability.

For further details, please see: https://docs.opencv.org/master/d2/da2/classcv_1_1TrackerCSRT.html

func (TrackerCSRT) Close added in v0.16.0

func (trk TrackerCSRT) Close() error

Close closes this Tracker.

func (TrackerCSRT) Init added in v0.16.0

func (trk TrackerCSRT) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes this Tracker.

func (TrackerCSRT) Update added in v0.16.0

func (trk TrackerCSRT) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates this Tracker.

type TrackerKCF added in v0.16.0

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

TrackerKCF is a Tracker based on KCF, which is a novel tracking framework that utilizes properties of circulant matrix to enhance the processing speed.

For further details, please see: https://docs.opencv.org/master/d2/dff/classcv_1_1TrackerKCF.html

func (TrackerKCF) Close added in v0.16.0

func (trk TrackerKCF) Close() error

Close closes this Tracker.

func (TrackerKCF) Init added in v0.16.0

func (trk TrackerKCF) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes this Tracker.

func (TrackerKCF) Update added in v0.16.0

func (trk TrackerKCF) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates this Tracker.

type TrackerMIL added in v0.16.0

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

TrackerMIL is a Tracker that uses the MIL algorithm. MIL trains a classifier in an online manner to separate the object from the background. Multiple Instance Learning avoids the drift problem for a robust tracking.

For further details, please see: https://docs.opencv.org/master/d0/d26/classcv_1_1TrackerMIL.html

func (TrackerMIL) Close added in v0.16.0

func (trk TrackerMIL) Close() error

Close closes the TrackerMIL.

func (TrackerMIL) Init added in v0.16.0

func (trk TrackerMIL) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes the TrackerMIL.

func (TrackerMIL) Update added in v0.16.0

func (trk TrackerMIL) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates the TrackerMIL.

type TrackerMOSSE added in v0.16.0

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

TrackerMOSSE uses Visual Object Tracking using Adaptive Correlation Filters. Note, that this tracker only works on graysccale images.

For further details, please see: https://docs.opencv.org/master/d0/d02/classcv_1_1TrackerMOSSE.html

func (TrackerMOSSE) Close added in v0.16.0

func (trk TrackerMOSSE) Close() error

Close closes this Tracker.

func (TrackerMOSSE) Init added in v0.16.0

func (trk TrackerMOSSE) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes this Tracker.

func (TrackerMOSSE) Update added in v0.16.0

func (trk TrackerMOSSE) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates this Tracker.

type TrackerMedianFlow added in v0.16.0

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

TrackerMedianFlow is a Tracker implementation suitable for very smooth and predictable movements when the object is visible throughout the whole sequence.

For further details, please see: https://docs.opencv.org/master/d7/d86/classcv_1_1TrackerMedianFlow.html

func (TrackerMedianFlow) Close added in v0.16.0

func (trk TrackerMedianFlow) Close() error

Close closes the Tracker.

func (TrackerMedianFlow) Init added in v0.16.0

func (trk TrackerMedianFlow) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes the Tracker.

func (TrackerMedianFlow) Update added in v0.16.0

func (trk TrackerMedianFlow) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates the Tracker.

type TrackerTLD added in v0.16.0

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

TrackerTLD is a novel tracking framework that explicitly decomposes the long-term tracking task into tracking, learning and detection.

For further details, please see: https://docs.opencv.org/master/dc/d1c/classcv_1_1TrackerTLD.html

func (TrackerTLD) Close added in v0.16.0

func (trk TrackerTLD) Close() error

Close closes this Tracker.

func (TrackerTLD) Init added in v0.16.0

func (trk TrackerTLD) Init(img gocv.Mat, boundingBox image.Rectangle) bool

Init initializes this Tracker.

func (TrackerTLD) Update added in v0.16.0

func (trk TrackerTLD) Update(img gocv.Mat) (image.Rectangle, bool)

Update updates this Tracker.

Jump to

Keyboard shortcuts

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