keypoints

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 14 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, sp *SamplePairs, cfg *ORBConfig) ([]Descriptor, KeyPoints, error)

ComputeORBKeypoints compute ORB keypoints on gray image.

func DescriptorsHammingDistance added in v0.0.9

func DescriptorsHammingDistance(descs1, descs2 []Descriptor) ([][]int, error)

DescriptorsHammingDistance computes the pairwise distances between 2 descriptor arrays.

func GetMatchingKeyPoints

func GetMatchingKeyPoints(matches []DescriptorMatch, 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) image.Image

PlotKeypoints plots keypoints on image.

func PlotMatchedLines added in v0.0.9

func PlotMatchedLines(im1, im2 image.Image, kps1, kps2 []image.Point, vertical bool) image.Image

PlotMatchedLines plots matched keypoints on both images. vertical is true if the images should be stacked on top of each other.

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 = []uint64

Descriptor is an alias for a slice of uint64.

func ComputeBRIEFDescriptors

func ComputeBRIEFDescriptors(img *image.Gray, sp *SamplePairs, kps *FASTKeypoints, cfg *BRIEFConfig) ([]Descriptor, error)

ComputeBRIEFDescriptors computes BRIEF descriptors on image img at keypoints kps.

type DescriptorMatch

type DescriptorMatch struct {
	Idx1        int
	Idx2        int
	Score       int
	Descriptor1 Descriptor
	Descriptor2 Descriptor
}

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

func MatchDescriptors added in v0.0.9

func MatchDescriptors(desc1, desc2 []Descriptor, cfg *MatchingConfig, logger logging.Logger) []DescriptorMatch

MatchDescriptors takes 2 sets of descriptors and performs matching. Order orders: desc1 are being matched to desc2.

type FASTConfig

type FASTConfig struct {
	NMatchesCircle int  `json:"n_matches"`
	NMSWinSize     int  `json:"nms_win_size_px"`
	Threshold      int  `json:"threshold"` // between 0 and 255, represents a unit of grayscale intensity of the pixel
	Oriented       bool `json:"oriented"`
	Radius         int  `json:"radius_px"`
}

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 - int, Threshold used to decide whether the pixels on the circle are brighter, darker or similar w.r.t. the test pixel. Given in absolute units. 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      int  `json:"max_dist_bits"`
}

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 SamplePairs added in v0.0.9

type SamplePairs struct {
	P0 []image.Point
	P1 []image.Point
	N  int
}

SamplePairs are N pairs of points used to create the BRIEF Descriptors of a patch.

func GenerateSamplePairs added in v0.0.9

func GenerateSamplePairs(dist SamplingType, n, patchSize int) *SamplePairs

GenerateSamplePairs generates n samples for a patch size with the chosen Sampling Type.

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