Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f2978bc

Browse files
committedMay 11, 2018
Extracción de puntos clave
Usaremos los algoritmos ORB, BRISK, AKAZE, entre otros.
1 parent 4d26b5a commit f2978bc

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
 

‎opencv-keypoints/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.4)
2+
3+
project( Tutorial_Keypoints )
4+
5+
find_package( OpenCV 3.0.0 REQUIRED )
6+
7+
file(COPY images DESTINATION data)
8+
9+
add_executable( ${PROJECT_NAME} source.cpp)
10+
target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS} )

‎opencv-keypoints/images/box.png

49.5 KB
Loading
120 KB
Loading

‎opencv-keypoints/source.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <iostream>
2+
#include <opencv2\opencv.hpp>
3+
#include <opencv2\features2d.hpp>
4+
5+
using namespace cv;
6+
using namespace std;
7+
8+
int main(int argc, char** argv )
9+
{
10+
Mat imageA = imread("data/images/box.png", IMREAD_GRAYSCALE);
11+
Mat imageB = imread("data/images/box_in_scene.png", IMREAD_GRAYSCALE);
12+
13+
if (imageA.empty() || imageB.empty())
14+
{
15+
printf("No image data.");
16+
getchar();
17+
18+
return -1;
19+
}
20+
21+
Ptr<Feature2D> detect = BRISK::create();
22+
23+
vector<KeyPoint> kpA, kpB;
24+
Mat descA, descB;
25+
26+
detect->detectAndCompute(imageA, noArray(), kpA, descA);
27+
detect->detectAndCompute(imageB, noArray(), kpB, descB);
28+
29+
vector<DMatch> matches;
30+
31+
Ptr<DescriptorMatcher> matcher = BFMatcher::create(NORM_HAMMING, true);
32+
matcher->match(descA, descB, matches);
33+
34+
sort(matches.begin(), matches.end());
35+
matches.erase(matches.begin() + 35, matches.end());
36+
37+
Scalar color = Scalar::all(-1);
38+
int flags = DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS;
39+
40+
Mat result;
41+
drawMatches(imageA, kpA, imageB, kpB, matches, result, color, color, vector<char>(), flags);
42+
43+
imshow("OpenCV :: Match Keypoints", result);
44+
waitKey(0);
45+
46+
return 0;
47+
}

0 commit comments

Comments
 (0)
Please sign in to comment.