1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Sample files for image scanning, basic Mat, file I/O. Added Victors removed tutorials back in the system. Some typo fixing.Expanded conf.py with new global links.

This commit is contained in:
Bernat Gabor
2011-07-22 15:11:59 +00:00
parent 3d9cb082c9
commit ffe7a658fb
21 changed files with 1373 additions and 11 deletions
@@ -0,0 +1,72 @@
.. _detectionOfPlanarObjects:
Detection of planar objects
***************************
.. highlight:: cpp
The goal of this tutorial is to learn how to use *features2d* and *calib3d* modules for detecting known planar objects in scenes.
*Test data*: use images in your data folder, for instance, ``box.png`` and ``box_in_scene.png``.
#.
Create a new console project. Read two input images. ::
Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
#.
Detect keypoints in both images. ::
// detecting keypoints
FastFeatureDetector detector(15);
vector<KeyPoint> keypoints1;
detector.detect(img1, keypoints1);
... // do the same for the second image
#.
Compute descriptors for each of the keypoints. ::
// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1;
extractor.compute(img1, keypoints1, descriptors1);
... // process keypoints from the second image as well
#.
Now, find the closest matches between descriptors from the first image to the second: ::
// matching descriptors
BruteForceMatcher<L2<float> > matcher;
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
#.
Visualize the results: ::
// drawing the results
namedWindow("matches", 1);
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
#.
Find the homography transformation between two sets of points: ::
vector<Point2f> points1, points2;
// fill the arrays with the points
....
Mat H = findHomography(Mat(points1), Mat(points2), CV_RANSAC, ransacReprojThreshold);
#.
Create a set of inlier matches and draw them. Use perspectiveTransform function to map points with homography:
Mat points1Projected;
perspectiveTransform(Mat(points1), points1Projected, H);
#.
Use ``drawMatches`` for drawing inliers.
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

@@ -86,6 +86,25 @@ Learn about how to use the feature points detectors, descriptors and matching f
:height: 90pt
:width: 90pt
+
.. tabularcolumns:: m{100pt} m{300pt}
.. cssclass:: toctableopencv
===================== ==============================================
|DetectPlanar| **Title:** :ref:`detectionOfPlanarObjects`
*Compatibility:* > OpenCV 2.0
*Author:* |Author_VictorE|
You will use *features2d* and *calib3d* modules for detecting known planar objects in scenes.
===================== ==============================================
.. |DetectPlanar| image:: images/detection_of_planar_objects.png
:height: 90pt
:width: 90pt
.. raw:: latex
\pagebreak
@@ -97,3 +116,4 @@ Learn about how to use the feature points detectors, descriptors and matching f
../trackingmotion/good_features_to_track/good_features_to_track.rst
../trackingmotion/generic_corner_detector/generic_corner_detector
../trackingmotion/corner_subpixeles/corner_subpixeles
../detection_of_planar_objects/detection_of_planar_objects