From 0d03716b3e6e08420f1a98cc1308cb1d5a844716 Mon Sep 17 00:00:00 2001 From: Pericles Telemachou Date: Thu, 26 Oct 2023 13:15:39 +1100 Subject: [PATCH] Squashed commit of the following: commit 2c36353cdfd7d510224a4ef16e3e96e05358ccf5 Author: Pericles Telemachou Date: Thu Oct 26 12:39:52 2023 +1100 Asserting some algorithms conform to `Feature2D` commit 665eef3ed1fa7840aad4448f2d3d4ac31d1aa8de Author: Pericles Telemachou Date: Thu Oct 26 12:39:04 2023 +1100 Add interface for `Feature2D` algorithms --- contrib/xfeatures2d.go | 2 ++ features2d.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/contrib/xfeatures2d.go b/contrib/xfeatures2d.go index 2d2d5889..883c3d94 100644 --- a/contrib/xfeatures2d.go +++ b/contrib/xfeatures2d.go @@ -21,6 +21,8 @@ type SURF struct { p unsafe.Pointer } +var _ gocv.Feature2D = (*SURF)(nil) + // NewSURF returns a new SURF algorithm. // // For further details, please see: diff --git a/features2d.go b/features2d.go index 2f33400a..1269dacd 100644 --- a/features2d.go +++ b/features2d.go @@ -7,16 +7,38 @@ package gocv import "C" import ( "image/color" + "io" "reflect" "unsafe" ) +type Detector interface { + Detect(src Mat) []KeyPoint +} + +type Computer interface { + Compute(src Mat, mask Mat, kps []KeyPoint) ([]KeyPoint, Mat) +} + +type DetectComputer interface { + DetectAndCompute(src Mat, mask Mat) ([]KeyPoint, Mat) +} + +type Feature2D interface { + io.Closer + Detector + Computer + DetectComputer +} + // AKAZE is a wrapper around the cv::AKAZE algorithm. type AKAZE struct { // C.AKAZE p unsafe.Pointer } +var _ Feature2D = (*AKAZE)(nil) + // NewAKAZE returns a new AKAZE algorithm // // For further details, please see: @@ -120,6 +142,8 @@ type BRISK struct { p unsafe.Pointer } +var _ Feature2D = (*BRISK)(nil) + // NewBRISK returns a new BRISK algorithm // // For further details, please see: @@ -278,6 +302,8 @@ type KAZE struct { p unsafe.Pointer } +var _ Feature2D = (*KAZE)(nil) + // NewKAZE returns a new KAZE algorithm // // For further details, please see: @@ -381,6 +407,8 @@ type ORB struct { p unsafe.Pointer } +var _ Feature2D = (*ORB)(nil) + // NewORB returns a new ORB algorithm // // For further details, please see: @@ -905,6 +933,8 @@ type SIFT struct { p unsafe.Pointer } +var _ Feature2D = (*SIFT)(nil) + // NewSIFT returns a new SIFT algorithm. // // For further details, please see: