Feature detectors and descriptors

Functions

Functions and classes to detect and describe image features

Bundles OpenCV feature detectors and descriptors into the FeatureDD class

Also makes it easier to mix and match feature detectors and descriptors from different pacakges (e.g. skimage and OpenCV). See CensureVggFD for an example

valis.feature_detectors.filter_features(kp, desc, n_keep=7500)[source]

Get keypoints with highest response

Parameters:
  • kp (list) – List of cv2.KeyPoint detected by an OpenCV feature detector.

  • desc (ndarray) – 2D numpy array of keypoint descriptors, where each row is a keypoint and each column a feature.

  • n_keep (int) – Maximum number of features that are retained.

Returns:

  • Keypoints and and corresponding descriptors that the the n_keep highest

  • responses.

Classes

Base feature detector

class valis.feature_detectors.FeatureDD(kp_detector=None, kp_descriptor=None, rgb=False, n_levels=1)[source]

Abstract class for feature detection and description.

User can create other feature detectors as subclasses, but each must return keypoint positions in xy coordinates along with the descriptors for each keypoint.

Note that in some cases, such as KAZE, kp_detector can also detect features. However, in other cases, there may need to be a separate feature detector (like BRISK or ORB) and feature descriptor (like VGG).

kp_detector

Keypoint detetor, by default from OpenCV

Type:

object

kp_descriptor

Keypoint descriptor, by default from OpenCV

Type:

object

kp_detector_name

Name of keypoint detector

Type:

str

kp_descriptor

Name of keypoint descriptor

Type:

str

detectAndCompute(image, mask=None)

Detects and describes keypoints in image

__init__(kp_detector=None, kp_descriptor=None, rgb=False, n_levels=1)[source]
Parameters:
  • kp_detector (object) – Keypoint detetor, by default from OpenCV

  • kp_descriptor (object) – Keypoint descriptor, by default from OpenCV

DISK

class valis.feature_detectors.DiskFD(kp_detector=<class 'kornia.feature.disk.disk.DISK'>, kp_descriptor=<class 'kornia.feature.disk.disk.DISK'>, num_features=7500, quant_image=True, rgb=False, device=None, *args, **kwargs)[source]

Bases: KorniaFD

DISK feature detector and descriptor, implemented in Kornia.

Citation

Michał Tyszkiewicz, Pascal Fua, and Eduard Trulls. Disk: learning local features with policy gradient. Advances in Neural Information Processing Systems, 33:14254–14265, 2020.

DeDoDe

class valis.feature_detectors.DeDoDeFD(kp_detector=<class 'kornia.feature.dedode.dedode.DeDoDe'>, kp_descriptor=<class 'kornia.feature.dedode.dedode.DeDoDe'>, num_features=7500, quant_image=True, rgb=False, device=None, *args, **kwargs)[source]

Bases: KorniaFD

DeDoDe feature detector and descriptor, implemented in Kornia.

Citation

Johan Edstedt, Georg Bökman, Mårten Wadenbäck, and Michael Felsberg. DeDoDe: Detect, Don’t Describe — Describe, Don’t Detect for Local Feature Matching. In 2024 International Conference on 3D Vision (3DV). 2024.

KorniaFD

class valis.feature_detectors.KorniaFD(kp_detector=None, kp_descriptor=None, num_features=7500, rgb=False, device=None, *args, **kwargs)[source]

Bases: FeatureDD

Abstract class for feature detectors implemented in Kornia

BRISK

class valis.feature_detectors.BriskFD(kp_descriptor=< cv2.BRISK 0x74bb5257d750>, *args, **kwargs)[source]

Bases: FeatureDD

Uses BRISK for feature detection and description

KAZE

class valis.feature_detectors.KazeFD(kp_descriptor=< cv2.KAZE 0x74bb5257d8d0>, *args, **kwargs)[source]

Bases: FeatureDD

Uses KAZE for feature detection and description

AKAZE

class valis.feature_detectors.AkazeFD(kp_descriptor=< cv2.AKAZE 0x74bb5257d810>, *args, **kwargs)[source]

Bases: FeatureDD

Uses AKAZE for feature detection and description

DAISY

class valis.feature_detectors.DaisyFD(kp_detector=< cv2.BRISK 0x74bb5257d3f0>, kp_descriptor=< cv2.xfeatures2d.DAISY 0x74bb5257dcd0>, *args, **kwargs)[source]

Bases: FeatureDD

Uses BRISK for feature detection and DAISY for feature description

LATCH

class valis.feature_detectors.LatchFD(kp_detector=< cv2.BRISK 0x74bb5257d3f0>, kp_descriptor=< cv2.xfeatures2d.LATCH 0x74bb5257de10>, *args, **kwargs)[source]

Bases: FeatureDD

Uses BRISK for feature detection and LATCH for feature description

BOOST

class valis.feature_detectors.BoostFD(kp_detector=< cv2.BRISK 0x74bb5257d3f0>, kp_descriptor=< cv2.xfeatures2d.BoostDesc 0x74bb5257d630>, *args, **kwargs)[source]

Bases: FeatureDD

Uses BRISK for feature detection and Boost for feature description

VGG

class valis.feature_detectors.VggFD(kp_detector=< cv2.BRISK 0x74bb5257d3f0>, kp_descriptor=< cv2.xfeatures2d.VGG 0x74bb5257dc70>, *args, **kwargs)[source]

Bases: FeatureDD

Uses BRISK for feature detection and VGG for feature description

Orb + Vgg

class valis.feature_detectors.OrbVggFD(kp_detector=< cv2.ORB 0x74bb5257da10>, kp_descriptor=< cv2.xfeatures2d.VGG 0x74bb5257df10>, *args, **kwargs)[source]

Bases: FeatureDD

Uses ORB for feature detection and VGG for feature description

SuperPoint

class valis.feature_detectors.SuperPointFD(keypoint_threshold=0.005, nms_radius=4, force_cpu=False, kp_descriptor=None, kp_detector=None, *args, **kwargs)[source]

Bases: FeatureDD

SuperPoint FeatureDD

Use SuperPoint to detect and describe features (detect_and_compute) Adapted from https://github.com/magicleap/SuperGluePretrainedNetwork/blob/master/match_pairs.py

References

Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. SuperGlue: Learning Feature Matching with Graph Neural Networks. In CVPR, 2020. https://arxiv.org/abs/1911.11763