OpenCV  4.2.0
Open Source Computer Vision
Feature Detection

.2.0+dfsg_doc_tutorials_features2d_feature_detection_feature_detection

Goal

In this tutorial you will learn how to:

  • Use the cv::FeatureDetector interface in order to find interest points. Specifically:
    • Use the cv::xfeatures2d::SURF and its function cv::xfeatures2d::SURF::detect to perform the detection process
    • Use the function cv::drawKeypoints to draw the detected keypoints
Warning
You need the OpenCV contrib modules to be able to use the SURF features (alternatives are ORB, KAZE, ... features).

Theory

Code

Explanation

Result

  1. Here is the result of the feature detection applied to the box.png image:

  2. And here is the result for the box_in_scene.png image:

cv::String
std::string String
Definition: cvstd.hpp:150
cv::imread
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
cv::samples::findFile
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
cv::waitKey
int waitKey(int delay=0)
Waits for a pressed key.
highgui.hpp
cv::IMREAD_GRAYSCALE
@ IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image (codec internal conversion).
Definition: imgcodecs.hpp:66
core.hpp
cv::Mat::empty
bool empty() const
Returns true if the array has no elements.
cv::dnn::print
static void print(const MatShape &shape, const String &name="")
Definition: shape_utils.hpp:188
cv::Ptr
std::shared_ptr< _Tp > Ptr
Definition: cvstd_wrapper.hpp:23
cv::imshow
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
features2d.hpp
cv::Mat
n-dimensional dense array class
Definition: mat.hpp:792
cv::imshow
void imshow(const String &winname, const ogl::Texture2D &tex)
Displays OpenGL 2D texture in the specified window.
cv::drawKeypoints
void drawKeypoints(InputArray image, const std::vector< KeyPoint > &keypoints, InputOutputArray outImage, const Scalar &color=Scalar::all(-1), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT)
Draws keypoints.
cv::CommandLineParser
Designed for command line parsing.
Definition: utility.hpp:797
cv
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:52