از آنجایی که مطلع هستید در ابتدا باید نقاط کلیدی (key point) را شناسایی کرده و سپس در هر نقطه کلیدی توصیفگر(discriptor) نقطه کلیدی مورد نظر را با 128 بعد توصیف می کند .در ضمن توابعی برای نمایش نقاط کلیدی نیز وجود داره.
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
Mat image = imread("TestImage.jpg");
// ijad esharegar hoshmand baraye noghate kilidi SIFT .
Ptr<FeatureDetector> featureDetector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;
// shenasayi noghate kilidi
featureDetector->detect(image, keypoints);
//ijad esharegar hoshmand baraye estekhraje vijegi SIFT
Ptr<DescriptorExtractor> featureExtractor = DescriptorExtractor::create("SIFT");
// mohasebe tosifgar 128 bodi baraye noghte kilidi
//har radif dar tosifgar marbote be to tosife ye noghte kilidi mibashad
Mat descriptors;
featureExtractor->compute(image, keypoints, descriptors);
//baraye rasme noghate kilidi az code zir estefade konid
Mat outputImage;
Scalar keypointColor = Scalar(255, 0, 0);
drawKeypoints(image, keypoints, outputImage, keypointColor, DrawMatchesFlags::DEFAULT);
namedWindow("Output");
imshow("Output", outputImage);
char c = ' ';
while ((c = waitKey(0)) != 'q');
return 0;
}