Merge remote-tracking branch 'upstream/master'
Conflicts: modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
This commit is contained in:
@@ -187,7 +187,7 @@ Explanation
|
||||
|
||||
image.convertTo(new_image, -1, alpha, beta);
|
||||
|
||||
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result.
|
||||
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result but convertTo is more optimized and works a lot faster.
|
||||
|
||||
Result
|
||||
=======
|
||||
|
@@ -25,7 +25,7 @@ Here's a sample usage of :operationsonarrays:`dft() <dft>` :
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-3, 5, 19-20, 23-78
|
||||
:lines: 1-4, 6, 20-21, 24-79
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
@@ -45,7 +45,7 @@ The final argument is optional. If given the image will be loaded in gray scale
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 48-60
|
||||
:lines: 49-61
|
||||
|
||||
Here we first use the C++ *stringstream* class to convert the third command line argument from text to an integer format. Then we use a simple look and the upper formula to calculate the lookup table. No OpenCV specific stuff here.
|
||||
|
||||
@@ -99,7 +99,7 @@ When it comes to performance you cannot beat the classic C style operator[] (poi
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 125-152
|
||||
:lines: 126-153
|
||||
|
||||
Here we basically just acquire a pointer to the start of each row and go through it until it ends. In the special case that the matrix is stored in a continues manner we only need to request the pointer a single time and go all the way to the end. We need to look out for color images: we have three channels so we need to pass through three times more items in each row.
|
||||
|
||||
@@ -122,7 +122,7 @@ In case of the efficient way making sure that you pass through the right amount
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 154-182
|
||||
:lines: 155-183
|
||||
|
||||
In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the *Vec3b* name. To access the n-th sub column we use simple operator[] access. It's important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple *uchar* iterator you'll be able to access only the blue channel values.
|
||||
|
||||
@@ -134,7 +134,7 @@ The final method isn't recommended for scanning. It was made to acquire or modif
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 184-216
|
||||
:lines: 185-217
|
||||
|
||||
The functions takes your input type and coordinates and calculates on the fly the address of the queried item. Then returns a reference to that. This may be a constant when you *get* the value and non-constant when you *set* the value. As a safety step in **debug mode only*** there is performed a check that your input coordinates are valid and does exist. If this isn't the case you'll get a nice output message of this on the standard error output stream. Compared to the efficient way in release mode the only difference in using this is that for every element of the image you'll get a new row pointer for what we use the C operator[] to acquire the column element.
|
||||
|
||||
@@ -148,14 +148,14 @@ This is a bonus method of achieving lookup table modification in an image. Becau
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 107-110
|
||||
:lines: 108-111
|
||||
|
||||
Finally call the function (I is our input image and J the output one):
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 115
|
||||
:lines: 116
|
||||
|
||||
Performance Difference
|
||||
======================
|
||||
|
@@ -77,7 +77,7 @@ Now that you have the basics done :download:`here's <../../../../samples/cpp/tut
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-9, 22-25, 27-44
|
||||
:lines: 1-10, 23-26, 29-46
|
||||
|
||||
Here you can observe that with the new structure we have no pointer problems, although it is possible to use the old functions and in the end just transform the result to a *Mat* object.
|
||||
|
||||
@@ -85,7 +85,7 @@ Here you can observe that with the new structure we have no pointer problems, al
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 46-51
|
||||
:lines: 48-53
|
||||
|
||||
Because, we want to mess around with the images luma component we first convert from the default RGB to the YUV color space and then split the result up into separate planes. Here the program splits: in the first example it processes each plane using one of the three major image scanning algorithms in OpenCV (C [] operator, iterator, individual element access). In a second variant we add to the image some Gaussian noise and then mix together the channels according to some formula.
|
||||
|
||||
@@ -95,7 +95,7 @@ The scanning version looks like:
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 55-75
|
||||
:lines: 57-77
|
||||
|
||||
Here you can observe that we may go through all the pixels of an image in three fashions: an iterator, a C pointer and an individual element access style. You can read a more in-depth description of these in the :ref:`howToScanImagesOpenCV` tutorial. Converting from the old function names is easy. Just remove the cv prefix and use the new *Mat* data structure. Here's an example of this by using the weighted addition function:
|
||||
|
||||
@@ -103,7 +103,7 @@ Here you can observe that we may go through all the pixels of an image in three
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 79-112
|
||||
:lines: 81-113
|
||||
|
||||
As you may observe the *planes* variable is of type *Mat*. However, converting from *Mat* to *IplImage* is easy and made automatically with a simple assignment operator.
|
||||
|
||||
@@ -111,7 +111,7 @@ As you may observe the *planes* variable is of type *Mat*. However, converting f
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 115-127
|
||||
:lines: 117-129
|
||||
|
||||
The new *imshow* highgui function accepts both the *Mat* and *IplImage* data structures. Compile and run the program and if the first image below is your input you may get either the first or second as output:
|
||||
|
||||
|
@@ -86,7 +86,7 @@ Each of the building components has their own valid domains. This leads to the d
|
||||
Creating a *Mat* object explicitly
|
||||
==================================
|
||||
|
||||
In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readwriteimagevideo:`imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
|
||||
In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readwriteimage:`imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
|
||||
|
||||
Although *Mat* works really well as an image container, it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
|
||||
|
||||
|
@@ -200,7 +200,6 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
=============== ======================================================
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
@@ -221,8 +220,6 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
:width: 90pt
|
||||
.. |Author_ElenaG| unicode:: Elena U+0020 Gvozdeva
|
||||
|
||||
=============== ======================================================
|
||||
|
||||
.. raw:: latex
|
||||
|
||||
\pagebreak
|
||||
|
161
doc/tutorials/features2d/akaze_matching/akaze_matching.rst
Normal file
161
doc/tutorials/features2d/akaze_matching/akaze_matching.rst
Normal file
@@ -0,0 +1,161 @@
|
||||
.. _akazeMatching:
|
||||
|
||||
|
||||
AKAZE local features matching
|
||||
******************************
|
||||
|
||||
Introduction
|
||||
------------------
|
||||
|
||||
In this tutorial we will learn how to use [AKAZE]_ local features to detect and match keypoints on two images.
|
||||
|
||||
We will find keypoints on a pair of images with given homography matrix,
|
||||
match them and count the number of inliers (i. e. matches that fit in the given homography).
|
||||
|
||||
You can find expanded version of this example here: https://github.com/pablofdezalc/test_kaze_akaze_opencv
|
||||
|
||||
.. [AKAZE] Fast Explicit Diffusion for Accelerated Features in Nonlinear Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
|
||||
|
||||
Data
|
||||
------------------
|
||||
We are going to use images 1 and 3 from *Graffity* sequence of Oxford dataset.
|
||||
|
||||
.. image:: images/graf.png
|
||||
:height: 200pt
|
||||
:width: 320pt
|
||||
:alt: Graffity
|
||||
:align: center
|
||||
|
||||
Homography is given by a 3 by 3 matrix:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
7.6285898e-01 -2.9922929e-01 2.2567123e+02
|
||||
3.3443473e-01 1.0143901e+00 -7.6999973e+01
|
||||
3.4663091e-04 -1.4364524e-05 1.0000000e+00
|
||||
|
||||
You can find the images (*graf1.png*, *graf3.png*) and homography (*H1to3p.xml*) in *opencv/samples/cpp*.
|
||||
|
||||
Source Code
|
||||
===========
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
||||
1. **Load images and homography**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat img1 = imread("graf1.png", IMREAD_GRAYSCALE);
|
||||
Mat img2 = imread("graf3.png", IMREAD_GRAYSCALE);
|
||||
|
||||
Mat homography;
|
||||
FileStorage fs("H1to3p.xml", FileStorage::READ);
|
||||
fs.getFirstTopLevelNode() >> homography;
|
||||
|
||||
We are loading grayscale images here. Homography is stored in the xml created with FileStorage.
|
||||
|
||||
2. **Detect keypoints and compute descriptors using AKAZE**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
vector<KeyPoint> kpts1, kpts2;
|
||||
Mat desc1, desc2;
|
||||
|
||||
AKAZE akaze;
|
||||
akaze(img1, noArray(), kpts1, desc1);
|
||||
akaze(img2, noArray(), kpts2, desc2);
|
||||
|
||||
We create AKAZE object and use it's *operator()* functionality. Since we don't need the *mask* parameter, *noArray()* is used.
|
||||
|
||||
3. **Use brute-force matcher to find 2-nn matches**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
BFMatcher matcher(NORM_HAMMING);
|
||||
vector< vector<DMatch> > nn_matches;
|
||||
matcher.knnMatch(desc1, desc2, nn_matches, 2);
|
||||
|
||||
We use Hamming distance, because AKAZE uses binary descriptor by default.
|
||||
|
||||
4. **Use 2-nn matches to find correct keypoint matches**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
for(size_t i = 0; i < nn_matches.size(); i++) {
|
||||
DMatch first = nn_matches[i][0];
|
||||
float dist1 = nn_matches[i][0].distance;
|
||||
float dist2 = nn_matches[i][1].distance;
|
||||
|
||||
if(dist1 < nn_match_ratio * dist2) {
|
||||
matched1.push_back(kpts1[first.queryIdx]);
|
||||
matched2.push_back(kpts2[first.trainIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
If the closest match is *ratio* closer than the second closest one, then the match is correct.
|
||||
|
||||
5. **Check if our matches fit in the homography model**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
for(int i = 0; i < matched1.size(); i++) {
|
||||
Mat col = Mat::ones(3, 1, CV_64F);
|
||||
col.at<double>(0) = matched1[i].pt.x;
|
||||
col.at<double>(1) = matched1[i].pt.y;
|
||||
|
||||
col = homography * col;
|
||||
col /= col.at<double>(2);
|
||||
float dist = sqrt( pow(col.at<double>(0) - matched2[i].pt.x, 2) +
|
||||
pow(col.at<double>(1) - matched2[i].pt.y, 2));
|
||||
|
||||
if(dist < inlier_threshold) {
|
||||
int new_i = inliers1.size();
|
||||
inliers1.push_back(matched1[i]);
|
||||
inliers2.push_back(matched2[i]);
|
||||
good_matches.push_back(DMatch(new_i, new_i, 0));
|
||||
}
|
||||
}
|
||||
|
||||
If the distance from first keypoint's projection to the second keypoint is less than threshold, then it it fits in the homography.
|
||||
|
||||
We create a new set of matches for the inliers, because it is required by the drawing function.
|
||||
|
||||
6. **Output results**
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat res;
|
||||
drawMatches(img1, inliers1, img2, inliers2, good_matches, res);
|
||||
imwrite("res.png", res);
|
||||
...
|
||||
|
||||
Here we save the resulting image and print some statistics.
|
||||
|
||||
Results
|
||||
=======
|
||||
|
||||
Found matches
|
||||
--------------
|
||||
|
||||
.. image:: images/res.png
|
||||
:height: 200pt
|
||||
:width: 320pt
|
||||
:alt: Matches
|
||||
:align: center
|
||||
|
||||
A-KAZE Matching Results
|
||||
--------------------------
|
||||
Keypoints 1: 2943
|
||||
|
||||
Keypoints 2: 3511
|
||||
|
||||
Matches: 447
|
||||
|
||||
Inliers: 308
|
||||
|
||||
Inliers Ratio: 0.689038
|
BIN
doc/tutorials/features2d/akaze_matching/images/graf.png
Normal file
BIN
doc/tutorials/features2d/akaze_matching/images/graf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
BIN
doc/tutorials/features2d/akaze_matching/images/res.png
Normal file
BIN
doc/tutorials/features2d/akaze_matching/images/res.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
@@ -183,6 +183,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
|
||||
|
||||
===================== ==============================================
|
||||
|AkazeMatch| **Title:** :ref:`akazeMatching`
|
||||
|
||||
*Compatibility:* > OpenCV 3.0
|
||||
|
||||
*Author:* Fedor Morozov
|
||||
|
||||
Use *AKAZE* local features to find correspondence between two images.
|
||||
|
||||
===================== ==============================================
|
||||
|
||||
.. |AkazeMatch| image:: images/AKAZE_Match_Tutorial_Cover.png
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
.. raw:: latex
|
||||
|
||||
\pagebreak
|
||||
@@ -201,3 +220,4 @@ Learn about how to use the feature points detectors, descriptors and matching f
|
||||
../feature_flann_matcher/feature_flann_matcher
|
||||
../feature_homography/feature_homography
|
||||
../detection_of_planar_objects/detection_of_planar_objects
|
||||
../akaze_matching/akaze_matching
|
||||
|
@@ -22,7 +22,7 @@ As a test case where to show off these using OpenCV I've created a small program
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-14, 28-29, 31-205
|
||||
:lines: 1-15, 29-31, 33-208
|
||||
|
||||
How to read a video stream (online-camera or offline-file)?
|
||||
===========================================================
|
||||
|
@@ -656,7 +656,7 @@ classes we're going to use:
|
||||
Results: Stored in vars *1, *2, *3, an exception in *e
|
||||
|
||||
user=> (import '[org.opencv.core Mat Size CvType]
|
||||
'[org.opencv.highgui Highgui]
|
||||
'[org.opencv.imgcodecs Imgcodecs]
|
||||
'[org.opencv.imgproc Imgproc])
|
||||
org.opencv.imgproc.Imgproc
|
||||
|
||||
|
@@ -373,7 +373,7 @@ Now modify src/main/java/HelloOpenCV.java so it contains the following Java code
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.objdetect.CascadeClassifier;
|
||||
|
||||
//
|
||||
@@ -387,7 +387,7 @@ Now modify src/main/java/HelloOpenCV.java so it contains the following Java code
|
||||
// Create a face detector from the cascade file in the resources
|
||||
// directory.
|
||||
CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
|
||||
Mat image = Highgui.imread(getClass().getResource("/lena.png").getPath());
|
||||
Mat image = Imgcodecs.imread(getClass().getResource("/lena.png").getPath());
|
||||
|
||||
// Detect faces in the image.
|
||||
// MatOfRect is a special container class for Rect.
|
||||
@@ -404,7 +404,7 @@ Now modify src/main/java/HelloOpenCV.java so it contains the following Java code
|
||||
// Save the visualized detection.
|
||||
String filename = "faceDetection.png";
|
||||
System.out.println(String.format("Writing %s", filename));
|
||||
Highgui.imwrite(filename, image);
|
||||
Imgcodecs.imwrite(filename, image);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,28 +39,28 @@ You'll almost always end up using the:
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 1-3
|
||||
:lines: 1-4
|
||||
|
||||
We also include the *iostream* to facilitate console line output and input. To avoid data structure and function name conflicts with other libraries, OpenCV has its own namespace: *cv*. To avoid the need appending prior each of these the *cv::* keyword you can import the namespace in the whole file by using the lines:
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 5-6
|
||||
:lines: 6-7
|
||||
|
||||
This is true for the STL library too (used for console I/O). Now, let's analyze the *main* function. We start up assuring that we acquire a valid image name argument from the command line.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 10-14
|
||||
:lines: 11-15
|
||||
|
||||
Then create a *Mat* object that will store the data of the loaded image.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 16
|
||||
:lines: 17
|
||||
|
||||
Now we call the :imread:`imread <>` function which loads the image name specified by the first argument (*argv[1]*). The second argument specifies the format in what we want the image. This may be:
|
||||
|
||||
@@ -73,7 +73,7 @@ Now we call the :imread:`imread <>` function which loads the image name specifie
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 17
|
||||
:lines: 18
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -88,21 +88,21 @@ After checking that the image data was loaded correctly, we want to display our
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:lines: 25
|
||||
:lines: 26
|
||||
:tab-width: 4
|
||||
|
||||
Finally, to update the content of the OpenCV window with a new image use the :imshow:`imshow <>` function. Specify the OpenCV window name to update and the image to use during this operation:
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:lines: 26
|
||||
:lines: 27
|
||||
:tab-width: 4
|
||||
|
||||
Because we want our window to be displayed until the user presses a key (otherwise the program would end far too quickly), we use the :wait_key:`waitKey <>` function whose only parameter is just how long should it wait for a user input (measured in milliseconds). Zero means to wait forever.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
:lines: 28
|
||||
:lines: 29
|
||||
:tab-width: 4
|
||||
|
||||
Result
|
||||
|
@@ -349,7 +349,7 @@ Now here's our recommendation for the structure of the tutorial (although, remem
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-8, 21-22, 24-
|
||||
:lines: 1-8, 21-23, 25-
|
||||
|
||||
After the directive you specify a relative path to the file from what to import. It has four options: the language to use, if you add the ``:linenos:`` the line numbers will be shown, you can specify the tab size with the ``:tab-width:`` and you do not need to load the whole file, you can show just the important lines. Use the *lines* option to do not show redundant information (such as the *help* function). Here basically you specify ranges, if the second range line number is missing than that means that until the end of the file. The ranges specified here do no need to be in an ascending order, you may even reorganize the structure of how you want to show your sample inside the tutorial.
|
||||
|
||||
@@ -361,16 +361,16 @@ Now here's our recommendation for the structure of the tutorial (although, remem
|
||||
|
||||
# ---- External links for tutorials -----------------
|
||||
extlinks = {
|
||||
'hgvideo' : ('http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None)
|
||||
'rwimg' : ('http://docs.opencv.org/modules/imgcodecs/doc/reading_and_writing_images.html#%s', None)
|
||||
}
|
||||
|
||||
In short here we defined a new **hgvideo** directive that refers to an external webpage link. Its usage is:
|
||||
In short here we defined a new **rwimg** directive that refers to an external webpage link. Its usage is:
|
||||
|
||||
.. code-block:: rst
|
||||
|
||||
A sample function of the highgui modules image write and read page is the :hgvideo:`imread() function <imread>`.
|
||||
A sample function of the highgui modules image write and read page is the :rwimg:`imread() function <imread>`.
|
||||
|
||||
Which turns to: A sample function of the highgui modules image write and read page is the :hgvideo:`imread() function <imread>`. The argument you give between the <> will be put in place of the ``%s`` in the upper definition, and as the link will anchor to the correct function. To find out the anchor of a given function just open up a web page, search for the function and click on it. In the address bar it should appear like: ``http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imread`` . Look here for the name of the directives for each page of the OpenCV reference manual. If none present for one of them feel free to add one for it.
|
||||
Which turns to: A sample function of the highgui modules image write and read page is the :rwimg:`imread() function <imread>`. The argument you give between the <> will be put in place of the ``%s`` in the upper definition, and as the link will anchor to the correct function. To find out the anchor of a given function just open up a web page, search for the function and click on it. In the address bar it should appear like: ``http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images.html#imread`` . Look here for the name of the directives for each page of the OpenCV reference manual. If none present for one of them feel free to add one for it.
|
||||
|
||||
For formulas you can add LATEX code that will translate in the web pages into images. You do this by using the *math* directive. A usage tip:
|
||||
|
||||
|
@@ -7,22 +7,24 @@ These steps have been tested for Ubuntu 10.04 but should work with other distros
|
||||
Required Packages
|
||||
=================
|
||||
|
||||
* GCC 4.4.x or later. This can be installed with:
|
||||
* GCC 4.4.x or later
|
||||
* CMake 2.8.7 or higher
|
||||
* Git
|
||||
* GTK+2.x or higher, including headers (libgtk2.0-dev)
|
||||
* pkg-config
|
||||
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
|
||||
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
|
||||
* [optional] libtbb2 libtbb-dev
|
||||
* [optional] libdc1394 2.x
|
||||
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
|
||||
|
||||
The packages can be installed using a terminal and the following commands or by using Synaptic Manager:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get install build-essential
|
||||
|
||||
* CMake 2.8.7 or higher;
|
||||
* Git;
|
||||
* GTK+2.x or higher, including headers (libgtk2.0-dev);
|
||||
* pkg-config;
|
||||
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
|
||||
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
|
||||
* [optional] libdc1394 2.x;
|
||||
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.
|
||||
|
||||
All the libraries above can be installed via Terminal or by using Synaptic Manager.
|
||||
[compiler] sudo apt-get install build-essential
|
||||
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
|
||||
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
|
||||
|
||||
Getting OpenCV Source Code
|
||||
==========================
|
||||
|
@@ -5,7 +5,7 @@ Load, Modify, and Save an Image
|
||||
|
||||
.. note::
|
||||
|
||||
We assume that by now you know how to load an image using :readwriteimagevideo:`imread <imread>` and to display it in a window (using :user_interface:`imshow <imshow>`). Read the :ref:`Display_Image` tutorial otherwise.
|
||||
We assume that by now you know how to load an image using :readwriteimage:`imread <imread>` and to display it in a window (using :user_interface:`imshow <imshow>`). Read the :ref:`Display_Image` tutorial otherwise.
|
||||
|
||||
Goals
|
||||
======
|
||||
@@ -14,9 +14,9 @@ In this tutorial you will learn how to:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Load an image using :readwriteimagevideo:`imread <imread>`
|
||||
* Load an image using :readwriteimage:`imread <imread>`
|
||||
* Transform an image from BGR to Grayscale format by using :miscellaneous_transformations:`cvtColor <cvtcolor>`
|
||||
* Save your transformed image in a file on disk (using :readwriteimagevideo:`imwrite <imwrite>`)
|
||||
* Save your transformed image in a file on disk (using :readwriteimage:`imwrite <imwrite>`)
|
||||
|
||||
Code
|
||||
======
|
||||
@@ -62,7 +62,7 @@ Here it is:
|
||||
Explanation
|
||||
============
|
||||
|
||||
#. We begin by loading an image using :readwriteimagevideo:`imread <imread>`, located in the path given by *imageName*. For this example, assume you are loading a RGB image.
|
||||
#. We begin by loading an image using :readwriteimage:`imread <imread>`, located in the path given by *imageName*. For this example, assume you are loading a RGB image.
|
||||
|
||||
#. Now we are going to convert our image from BGR to Grayscale format. OpenCV has a really nice function to do this kind of transformations:
|
||||
|
||||
@@ -76,9 +76,9 @@ Explanation
|
||||
|
||||
* a source image (*image*)
|
||||
* a destination image (*gray_image*), in which we will save the converted image.
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **CV_BGR2GRAY** (because of :readwriteimagevideo:`imread <imread>` has BGR default channel order in case of color images).
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **CV_BGR2GRAY** (because of :readwriteimage:`imread <imread>` has BGR default channel order in case of color images).
|
||||
|
||||
#. So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost after the program ends). To save it, we will use a function analagous to :readwriteimagevideo:`imread <imread>`: :readwriteimagevideo:`imwrite <imwrite>`
|
||||
#. So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost after the program ends). To save it, we will use a function analagous to :readwriteimage:`imread <imread>`: :readwriteimage:`imwrite <imwrite>`
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
@@ -32,7 +32,7 @@ Image Watch works with any existing project that uses OpenCV image objects (for
|
||||
|
||||
#include <iostream> // std::cout
|
||||
#include <opencv2/core/core.hpp> // cv::Mat
|
||||
#include <opencv2/highgui/highgui.hpp> // cv::imread()
|
||||
#include <opencv2/imgcodecs/imgcodecs.hpp> // cv::imread()
|
||||
#include <opencv2/imgproc/imgproc.hpp> // cv::Canny()
|
||||
|
||||
using namespace std;
|
||||
@@ -78,6 +78,8 @@ Make sure your active solution configuration (:menuselection:`Build --> Configur
|
||||
|
||||
Build your solution (:menuselection:`Build --> Build Solution`, or press *F7*).
|
||||
|
||||
Before continuing, do not forget to add the command line argument of your input image to your project (:menuselection:`Right click on project --> Properties --> Configuration Properties --> Debugging` and then set the field ``Command Arguments`` with the location of the image).
|
||||
|
||||
Now set a breakpoint on the source line that says
|
||||
|
||||
.. code-block:: c++
|
||||
|
@@ -80,7 +80,7 @@ We add a camera controller to the view controller and initialize it when the vie
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
|
||||
#import <opencv2/highgui/cap_ios.h>
|
||||
#import <opencv2/videoio/cap_ios.h>
|
||||
using namespace cv;
|
||||
|
||||
|
||||
|
@@ -105,8 +105,8 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat trainingDataMat(3, 2, CV_32FC1, trainingData);
|
||||
Mat labelsMat (3, 1, CV_32FC1, labels);
|
||||
Mat trainingDataMat(4, 2, CV_32FC1, trainingData);
|
||||
Mat labelsMat (4, 1, CV_32FC1, labels);
|
||||
|
||||
2. **Set up SVM's parameters**
|
||||
|
||||
|
@@ -73,7 +73,7 @@ You may also find the source code and these video file in the :file:`samples/cpp
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-11, 22-23, 26-
|
||||
:lines: 1-12, 23-24, 27-
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
Reference in New Issue
Block a user