908f2c69a14148c2e183836408d1c9ec10c1b09a
[platform/upstream/opencv.git] / doc / tutorials / features2d / feature_homography / feature_homography.markdown
1 Features2D + Homography to find a known object {#tutorial_feature_homography}
2 ==============================================
3
4 Goal
5 ----
6
7 In this tutorial you will learn how to:
8
9 -   Use the function @ref cv::findHomography to find the transform between matched keypoints.
10 -   Use the function @ref cv::perspectiveTransform to map the points.
11
12 \warning You need the <a href="https://github.com/opencv/opencv_contrib">OpenCV contrib modules</a> to be able to use the SURF features
13 (alternatives are ORB, KAZE, ... features).
14
15 Theory
16 ------
17
18 Code
19 ----
20
21 @add_toggle_cpp
22 This tutorial code's is shown lines below. You can also download it from
23 [here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.cpp)
24 @include samples/cpp/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.cpp
25 @end_toggle
26
27 @add_toggle_java
28 This tutorial code's is shown lines below. You can also download it from
29 [here](https://github.com/opencv/opencv/tree/3.4/samples/java/tutorial_code/features2D/feature_homography/SURFFLANNMatchingHomographyDemo.java)
30 @include samples/java/tutorial_code/features2D/feature_homography/SURFFLANNMatchingHomographyDemo.java
31 @end_toggle
32
33 @add_toggle_python
34 This tutorial code's is shown lines below. You can also download it from
35 [here](https://github.com/opencv/opencv/tree/3.4/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py)
36 @include samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py
37 @end_toggle
38
39 Explanation
40 -----------
41
42 Result
43 ------
44
45 -   And here is the result for the detected object (highlighted in green). Note that since the homography is estimated with a RANSAC approach,
46     detected false matches will not impact the homography calculation.
47
48     ![](images/Feature_Homography_Result.jpg)