keypoints

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package keypoints contains the implementation of keypoints in an image. For now: - FAST keypoints

Index

Constants

This section is empty.

Variables

View Source
var (
	// CrossIdx contains the neighbors coordinates in a 3-cross neighborhood.
	CrossIdx = []image.Point{{0, 3}, {3, 0}, {0, -3}, {-3, 0}}
	// CircleIdx contains the neighbors coordinates in a circle of radius 3 neighborhood.
	CircleIdx = []image.Point{
		{0, -3},
		{1, -3},
		{2, -2},
		{3, -1},
		{3, 0},
		{3, 1},
		{2, 2},
		{1, 3},
		{0, 3},
		{-1, 3},
		{-2, 2},
		{-3, 1},
		{-3, 0},
		{-3, -1},
		{-2, -2},
		{-1, -3},
	}
)

Functions

func ComputeKeypointsOrientations

func ComputeKeypointsOrientations(img *image.Gray, kps KeyPoints, radius int) []float64

ComputeKeypointsOrientations compute keypoints orientations in image.

func ComputeORBKeypoints

func ComputeORBKeypoints(im *image.Gray, cfg *ORBConfig) (Descriptors, KeyPoints, error)

ComputeORBKeypoints compute ORB keypoints on gray image.

func GetMatchingKeyPoints

func GetMatchingKeyPoints(matches *DescriptorMatches, kps1, kps2 KeyPoints) (KeyPoints, KeyPoints, error)

GetMatchingKeyPoints takes the matches and the keypoints and returns the corresponding keypoints that are matched.

func GetNumberOctaves

func GetNumberOctaves(imgSize image.Point) int

GetNumberOctaves returns the number of scales (or Octaves) in the Pyramid computed from the image size.

func GetPointValuesInNeighborhood

func GetPointValuesInNeighborhood(img *image.Gray, coords image.Point, neighborhood []image.Point) []float64

GetPointValuesInNeighborhood returns a slice of floats containing the values of neighborhood pixels in image img.

func PlotKeypoints

func PlotKeypoints(img *image.Gray, kps []image.Point, outName string) error

PlotKeypoints plots keypoints on image.

Types

type BRIEFConfig

type BRIEFConfig struct {
	N              int          `json:"n"` // number of samples taken
	Sampling       SamplingType `json:"sampling"`
	UseOrientation bool         `json:"use_orientation"`
	PatchSize      int          `json:"patch_size"`
}

BRIEFConfig stores the parameters.

func LoadBRIEFConfiguration

func LoadBRIEFConfiguration(file string) *BRIEFConfig

LoadBRIEFConfiguration loads a BRIEFConfig from a json file.

type Descriptor

type Descriptor []float64

Descriptor stores a descriptor in a slice of float64.

type DescriptorMatch

type DescriptorMatch struct {
	Idx1 int
	Idx2 int
}

DescriptorMatch contains the index of a match in the first and second set of descriptors.

type DescriptorMatches

type DescriptorMatches struct {
	Indices      []DescriptorMatch
	Descriptors1 Descriptors
	Descriptors2 Descriptors
}

DescriptorMatches contains the descriptors and their matches.

func MatchKeypoints

func MatchKeypoints(desc1, desc2 Descriptors, cfg *MatchingConfig, logger golog.Logger) *DescriptorMatches

MatchKeypoints takes 2 sets of descriptors and performs matching.

type Descriptors

type Descriptors []Descriptor

Descriptors stores a slice of Descriptor.

func ComputeBRIEFDescriptors

func ComputeBRIEFDescriptors(img *image.Gray, kps *FASTKeypoints, cfg *BRIEFConfig) (Descriptors, error)

ComputeBRIEFDescriptors computes BRIEF descriptors on image img at keypoints kps.

type FASTConfig

type FASTConfig struct {
	NMatchesCircle int     `json:"n_matches"`
	NMSWinSize     int     `json:"nms_win_size"`
	Threshold      float64 `json:"threshold"`
	Oriented       bool    `json:"oriented"`
	Radius         int     `json:"radius"`
}

FASTConfig holds the parameters necessary to compute the FAST keypoints.

func LoadFASTConfiguration

func LoadFASTConfiguration(file string) *FASTConfig

LoadFASTConfiguration loads a FASTConfig from a json file.

type FASTKeypoints

type FASTKeypoints OrientedKeypoints

FASTKeypoints stores keypoint locations and orientations (nil if not oriented).

func NewFASTKeypointsFromImage

func NewFASTKeypointsFromImage(img *image.Gray, cfg *FASTConfig) *FASTKeypoints

NewFASTKeypointsFromImage returns a pointer to a FASTKeypoints struct containing keypoints locations and orientations if Oriented is set to true in the configuration.

func (*FASTKeypoints) IsOriented

func (kps *FASTKeypoints) IsOriented() bool

IsOriented returns true if FASTKeypoints contains orientations.

type FASTPixel

type FASTPixel struct {
	Point image.Point
	Type  PixelType
}

FASTPixel stores coordinates of an image point in a neighborhood and its PixelType.

type ImagePyramid

type ImagePyramid struct {
	Images []*image.Gray
	Scales []int
}

ImagePyramid contains a slice of an image and its downscaled images as well as the corresponding scales wrt the original image.

func GetImagePyramid

func GetImagePyramid(img *image.Gray) (*ImagePyramid, error)

GetImagePyramid return the images in the pyramid as well as the scales corresponding to each image in the ImagePyramid struct.

type KeyPoint

type KeyPoint image.Point // keypoint type

KeyPoint is an image.Point that contains coordinates of a kp.

type KeyPoints

type KeyPoints []image.Point // set of keypoints type

KeyPoints is a slice of image.Point that contains several kps.

func ComputeFAST

func ComputeFAST(img *image.Gray, cfg *FASTConfig) KeyPoints

ComputeFAST computes the location of FAST keypoints. The configuration should contain the following parameters

  • nMatchCircle - Minimum number of consecutive pixels out of 16 pixels on the circle that should all be either brighter or darker w.r.t test-pixel. A point c on the circle is darker w.r.t test pixel p if “Ic < Ip - threshold“ and brighter if “Ic > Ip + threshold“.
  • nmsWin - int, size of window to perform non-maximum suppression
  • threshold - float64, Threshold used to decide whether the pixels on the circle are brighter, darker or similar w.r.t. the test pixel. Decrease the threshold when more corners are desired and vice-versa.

func RescaleKeypoints

func RescaleKeypoints(kps KeyPoints, scaleFactor int) KeyPoints

RescaleKeypoints rescales given keypoints wrt scaleFactor.

type MatchingConfig

type MatchingConfig struct {
	DoCrossCheck bool    `json:"do_cross_check"`
	MaxDist      float64 `json:"max_dist"`
}

MatchingConfig contains the parameters for matching descriptors.

type ORBConfig

type ORBConfig struct {
	Layers          int          `json:"n_layers"`
	DownscaleFactor int          `json:"downscale_factor"`
	FastConf        *FASTConfig  `json:"fast"`
	BRIEFConf       *BRIEFConfig `json:"brief"`
}

ORBConfig contains the parameters / configs needed to compute ORB features.

func LoadORBConfiguration

func LoadORBConfiguration(file string) (*ORBConfig, error)

LoadORBConfiguration loads a ORBConfig from a json file.

func (*ORBConfig) Validate

func (config *ORBConfig) Validate(path string) error

Validate ensures all parts of the ORBConfig are valid.

type OrientedKeypoints

type OrientedKeypoints struct {
	Points       KeyPoints
	Orientations []float64
}

OrientedKeypoints stores keypoint locations and orientations (nil if not oriented).

type PixelType

type PixelType int

PixelType stores 0 if a pixel is darker than center pixel, and 1 if brighter.

type SamplingType

type SamplingType int

SamplingType stores 0 if a sampling of image points for BRIEF is uniform, 1 if gaussian.

Jump to

Keyboard shortcuts

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