mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #29073 from abhishek-gola:disk_feature_extractor
Added DISK feature extractor support #29073 closes: https://github.com/opencv/opencv/issues/27083 Merge with: https://github.com/opencv/opencv_extra/pull/1368/ ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -669,9 +669,88 @@ public:
|
||||
|
||||
CV_WRAP virtual void setK(double k) = 0;
|
||||
CV_WRAP virtual double getK() const = 0;
|
||||
|
||||
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENCV_DNN) || defined(CV_DOXYGEN)
|
||||
|
||||
/** @brief DISK feature detector and descriptor, based on a DNN model.
|
||||
|
||||
DISK (Deep Image Structure and Keypoints) is a learned local-feature pipeline that produces
|
||||
keypoints and 128-D L2-normalized descriptors via a single forward pass through a fully
|
||||
convolutional network. This class wraps an ONNX export of the pre-trained DISK model through
|
||||
cv::dnn::Net and exposes it under the standard cv::Feature2D interface so it can be used as
|
||||
a drop-in alternative to SIFT/ORB.
|
||||
|
||||
The class assumes the ONNX model has a single input named `image` taking an N×3×H×W float32
|
||||
tensor in [0, 1] (RGB channel order) and three outputs named `keypoints` (N×2), `scores` (N)
|
||||
and `descriptors` (N×128).
|
||||
*/
|
||||
class CV_EXPORTS_W DISK : public Feature2D
|
||||
{
|
||||
public:
|
||||
/** @brief Creates a DISK detector.
|
||||
@param modelPath Path to the DISK ONNX model.
|
||||
@param maxKeypoints Maximum number of keypoints to return per image. The strongest
|
||||
responses (by network score) are kept; -1 keeps all detections.
|
||||
@param scoreThreshold Discard keypoints with network score strictly below this value.
|
||||
@param imageSize Target input size (width, height) fed to the network. Use Size()
|
||||
(the default) to fall back to the network's expected fixed input
|
||||
shape of 1024x1024. When overriding, both dimensions must be
|
||||
positive multiples of 16, since DISK downsamples by a factor of 16.
|
||||
@param backendId DNN backend identifier (see cv::dnn::Backend); 0 = DNN_BACKEND_DEFAULT.
|
||||
@param targetId DNN target identifier (see cv::dnn::Target); 0 = DNN_TARGET_CPU.
|
||||
*/
|
||||
CV_WRAP static Ptr<DISK> create(const String& modelPath,
|
||||
int maxKeypoints = -1,
|
||||
float scoreThreshold = 0.0f,
|
||||
const Size& imageSize = Size(),
|
||||
int backendId = 0,
|
||||
int targetId = 0);
|
||||
|
||||
/** @brief Creates a DISK detector from an in-memory model buffer.
|
||||
|
||||
This overload loads the DISK ONNX model from a buffer instead of a file on disk. It is
|
||||
intended for cases where the model is read from application resources (for example Android
|
||||
assets) and is not available as a path on the filesystem.
|
||||
|
||||
@param bufferModel A buffer containing the contents of the DISK ONNX model.
|
||||
@param maxKeypoints Maximum number of keypoints to return per image. The strongest
|
||||
responses (by network score) are kept; -1 keeps all detections.
|
||||
@param scoreThreshold Discard keypoints with network score strictly below this value.
|
||||
@param imageSize Target input size (width, height) fed to the network. Use Size()
|
||||
(the default) to fall back to the network's expected fixed input
|
||||
shape of 1024x1024. When overriding, both dimensions must be
|
||||
positive multiples of 16, since DISK downsamples by a factor of 16.
|
||||
@param backendId DNN backend identifier (see cv::dnn::Backend); 0 = DNN_BACKEND_DEFAULT.
|
||||
@param targetId DNN target identifier (see cv::dnn::Target); 0 = DNN_TARGET_CPU.
|
||||
|
||||
@note In C++ this is an overload of @ref create. The Python/Java/Objective-C bindings expose
|
||||
it as `createFromMemory`, because Objective-C selectors are not disambiguated by argument
|
||||
type and would otherwise clash with the file-path @ref create.
|
||||
*/
|
||||
CV_WRAP_AS(createFromMemory) static Ptr<DISK> create(const std::vector<uchar>& bufferModel,
|
||||
int maxKeypoints = -1,
|
||||
float scoreThreshold = 0.0f,
|
||||
const Size& imageSize = Size(),
|
||||
int backendId = 0,
|
||||
int targetId = 0);
|
||||
|
||||
CV_WRAP virtual void setMaxKeypoints(int maxKeypoints) = 0;
|
||||
CV_WRAP virtual int getMaxKeypoints() const = 0;
|
||||
|
||||
CV_WRAP virtual void setScoreThreshold(float threshold) = 0;
|
||||
CV_WRAP virtual float getScoreThreshold() const = 0;
|
||||
|
||||
CV_WRAP virtual void setImageSize(const Size& size) = 0;
|
||||
CV_WRAP virtual Size getImageSize() const = 0;
|
||||
|
||||
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // HAVE_OPENCV_DNN || CV_DOXYGEN
|
||||
|
||||
/** @brief Class for extracting blobs from an image. :
|
||||
|
||||
The class implements a simple algorithm for extracting blobs from an image:
|
||||
|
||||
Reference in New Issue
Block a user