mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Updated broken links of tutorials in core and fixed weird-looking bullets (error of mine)
This commit is contained in:
parent
8b0092eaf5
commit
a0d73eadd3
@ -8,11 +8,13 @@ Goal
|
||||
|
||||
In this tutorial you will learn how to:
|
||||
|
||||
* What is *linear blending* and why it is useful.
|
||||
* Add two images using :add_weighted:`addWeighted <>`
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
Cool Theory
|
||||
=================
|
||||
* What is *linear blending* and why it is useful.
|
||||
* Add two images using :add_weighted:`addWeighted <>`
|
||||
|
||||
Theory
|
||||
=======
|
||||
|
||||
.. note::
|
||||
|
||||
@ -24,12 +26,12 @@ From our previous tutorial, we know already a bit of *Pixel operators*. An inter
|
||||
|
||||
g(x) = (1 - \alpha)f_{0}(x) + \alpha f_{1}(x)
|
||||
|
||||
By varying :math:`\alpha` from :math:`0 \rightarrow 1` this operator can be used to perform a temporal *cross-disolve* between two images or videos, as seen in slide shows and film production (cool, eh?)
|
||||
By varying :math:`\alpha` from :math:`0 \rightarrow 1` this operator can be used to perform a temporal *cross-disolve* between two images or videos, as seen in slide shows and film productions (cool, eh?)
|
||||
|
||||
Code
|
||||
=====
|
||||
|
||||
As usual, after the not-so-lengthy explanation, let's go to the code. Here it is:
|
||||
As usual, after the not-so-lengthy explanation, let's go to the code:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
@ -7,13 +7,15 @@ Goals
|
||||
======
|
||||
In this tutorial you will learn how to:
|
||||
|
||||
* Use :point:`Point <>` to define 2D points in an image.
|
||||
* Use :scalar:`Scalar <>` and why it is useful
|
||||
* Draw a **line** by using the OpenCV function :line:`line <>`
|
||||
* Draw an **ellipse** by using the OpenCV function :ellipse:`ellipse <>`
|
||||
* Draw a **rectangle** by using the OpenCV function :rectangle:`rectangle <>`
|
||||
* Draw a **circle** by using the OpenCV function :circle:`circle <>`
|
||||
* Draw a **filled polygon** by using the OpenCV function :fill_poly:`fillPoly <>`
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Use :point:`Point <>` to define 2D points in an image.
|
||||
* Use :scalar:`Scalar <>` and why it is useful
|
||||
* Draw a **line** by using the OpenCV function :line:`line <>`
|
||||
* Draw an **ellipse** by using the OpenCV function :ellipse:`ellipse <>`
|
||||
* Draw a **rectangle** by using the OpenCV function :rectangle:`rectangle <>`
|
||||
* Draw a **circle** by using the OpenCV function :circle:`circle <>`
|
||||
* Draw a **filled polygon** by using the OpenCV function :fill_poly:`fillPoly <>`
|
||||
|
||||
OpenCV Theory
|
||||
===============
|
||||
@ -22,7 +24,10 @@ For this tutorial, we will heavily use two structures: :point:`Point <>` and :sc
|
||||
|
||||
Point
|
||||
-------
|
||||
It represents a 2D point, specified by its image coordinates :math:`x` and :math:`y`. We can define it as:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
It represents a 2D point, specified by its image coordinates :math:`x` and :math:`y`. We can define it as:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -51,7 +56,7 @@ Scalar
|
||||
|
||||
Code
|
||||
=====
|
||||
* This code is in your OpenCV sample folder. Otherwise you can grab it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/Basic/Drawing_1.cpp>`_
|
||||
* This code is in your OpenCV sample folder. Otherwise you can grab it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp>`_
|
||||
|
||||
Explanation
|
||||
=============
|
||||
@ -126,6 +131,8 @@ Explanation
|
||||
|
||||
As we can see, *MyLine* just call the function :line:`line <>`, which does the following:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Draw a line from Point **start** to Point **end**
|
||||
* The line is displayed in the image **img**
|
||||
* The line color is defined by **Scalar( 0, 0, 0)** which is the RGB value correspondent to **Black**
|
||||
@ -154,6 +161,8 @@ Explanation
|
||||
|
||||
From the code above, we can observe that the function :ellipse:`ellipse <>` draws an ellipse such that:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* The ellipse is displayed in the image **img**
|
||||
* The ellipse center is located in the point **(w/2.0, w/2.0)** and is enclosed in a box of size **(w/4.0, w/16.0)**
|
||||
* The ellipse is rotated **angle** degrees
|
||||
@ -181,10 +190,12 @@ Explanation
|
||||
|
||||
Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* The image where the circle will be displayed (**img**)
|
||||
* The center of the circle denoted as the Point **center**
|
||||
* The radius of the circle: **w/32.0**
|
||||
* The color of the circle: **Scalar(0, 0, 255)** which means *Red* in RGB
|
||||
* The color of the circle: **Scalar(0, 0, 255)** which means *Red* in BGR
|
||||
* Since **thickness** = -1, the circle will be drawn filled.
|
||||
|
||||
* *MyPolygon*
|
||||
@ -231,11 +242,13 @@ Explanation
|
||||
|
||||
To draw a filled polygon we use the function :fill_poly:`fillPoly <>`. We note that:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* The polygon will be drawn on **img**
|
||||
* The vertices of the polygon are the set of points in **ppt**
|
||||
* The total number of vertices to be drawn are **npt**
|
||||
* The number of polygons to be drawn is only **1**
|
||||
* The color of the polygon is defined by **Scalar( 255, 255, 255)**, which is the RGB value for *white*
|
||||
* The color of the polygon is defined by **Scalar( 255, 255, 255)**, which is the BGR value for *white*
|
||||
|
||||
* *rectangle*
|
||||
|
||||
@ -250,9 +263,11 @@ Explanation
|
||||
|
||||
Finally we have the :rectangle:`rectangle <>` function (we did not create a special function for this guy). We note that:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* The rectangle will be drawn on **rook_image**
|
||||
* Two opposite vertices of the rectangle are defined by ** Point( 0, 7*w/8.0 )** and **Point( w, w)**
|
||||
* The color of the rectangle is given by **Scalar(0, 255, 255)** which is the RGB value for *yellow*
|
||||
* The color of the rectangle is given by **Scalar(0, 255, 255)** which is the BGR value for *yellow*
|
||||
* Since the thickness value is given by **-1**, the rectangle will be filled.
|
||||
|
||||
Result
|
||||
|
@ -18,8 +18,8 @@ In this tutorial you will learn how to:
|
||||
|
||||
+ Get some cool info about pixel transformations
|
||||
|
||||
Cool Theory
|
||||
=================
|
||||
Theory
|
||||
=======
|
||||
|
||||
.. note::
|
||||
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/>`_ by Richard Szeliski
|
||||
@ -27,32 +27,39 @@ Cool Theory
|
||||
Image Processing
|
||||
--------------------
|
||||
|
||||
* A general image processing operator is a function that takes one or more input images and produces an output image.
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Image transforms can be seen as:
|
||||
* A general image processing operator is a function that takes one or more input images and produces an output image.
|
||||
|
||||
* Point operators (pixel transforms)
|
||||
* Neighborhood (area-based) operators
|
||||
* Image transforms can be seen as:
|
||||
|
||||
+ Point operators (pixel transforms)
|
||||
+ Neighborhood (area-based) operators
|
||||
|
||||
|
||||
Pixel Transforms
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
* In this kind of image processing transform, each output pixel's value depends on only the corresponding input pixel value (plus, potentially, some globally collected information or parameters).
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Examples of such operators include *brightness and contrast adjustments* as well as color correction and transformations.
|
||||
* In this kind of image processing transform, each output pixel's value depends on only the corresponding input pixel value (plus, potentially, some globally collected information or parameters).
|
||||
|
||||
* Examples of such operators include *brightness and contrast adjustments* as well as color correction and transformations.
|
||||
|
||||
Brightness and contrast adjustments
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Two commonly used point processes are *multiplication* and *addition* with a constant:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Two commonly used point processes are *multiplication* and *addition* with a constant:
|
||||
|
||||
.. math::
|
||||
|
||||
g(x) = \alpha f(x) + \beta
|
||||
|
||||
* The parameters :math:`\alpha > 0` and :math:`\beta` are often called the *gain* and *bias* parameters; sometimes these parameters are said to control *contrast* and *brightness* respectively.
|
||||
* The parameters :math:`\alpha > 0` and :math:`\beta` are often called the *gain* and *bias* parameters; sometimes these parameters are said to control *contrast* and *brightness* respectively.
|
||||
|
||||
* You can think of :math:`f(x)` as the source image pixels and :math:`g(x)` as the output image pixels. Then, more conveniently we can write the expression as:
|
||||
* You can think of :math:`f(x)` as the source image pixels and :math:`g(x)` as the output image pixels. Then, more conveniently we can write the expression as:
|
||||
|
||||
.. math::
|
||||
|
||||
@ -63,8 +70,9 @@ Brightness and contrast adjustments
|
||||
Code
|
||||
=====
|
||||
|
||||
* The following code performs the operation :math:`g(i,j) = \alpha \cdot f(i,j) + \beta`
|
||||
* Here it is:
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* The following code performs the operation :math:`g(i,j) = \alpha \cdot f(i,j) + \beta` :
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -132,6 +140,8 @@ Explanation
|
||||
|
||||
#. Now, since we will make some transformations to this image, we need a new Mat object to store it. Also, we want this to have the following features:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Initial pixel values equal to zero
|
||||
* Same size and type as the original image
|
||||
|
||||
@ -155,6 +165,8 @@ Explanation
|
||||
|
||||
Notice the following:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* To access each pixel in the images we are using this syntax: *image.at<Vec3b>(y,x)[c]* where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
|
||||
|
||||
* Since the operation :math:`\alpha \cdot p(i,j) + \beta` can give values out of range or not integers (if :math:`\alpha` is float), we use :saturate_cast:`saturate_cast <>` to make sure the values are valid.
|
||||
|
@ -8,16 +8,21 @@ Goals
|
||||
|
||||
In this tutorial you will learn how to:
|
||||
|
||||
* Use the *Random Number generator class* (:rng:`RNG <>`) and how to get a random number from a uniform distribution.
|
||||
* Display text on an OpenCV window by using the function :put_text:`putText <>`
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Use the *Random Number generator class* (:rng:`RNG <>`) and how to get a random number from a uniform distribution.
|
||||
* Display text on an OpenCV window by using the function :put_text:`putText <>`
|
||||
|
||||
Code
|
||||
=====
|
||||
* In the previous tutorial (:ref:`Drawing_1`) we drew diverse geometric figures, giving as input parameters such as coordinates (in the form of :point:`Points <>`), color, thickness, etc. You might have noticed that we gave specific values for these arguments.
|
||||
|
||||
* In this tutorial, we intend to use *random* values for the drawing parameters. Also, we intend to populate our image with a big number of geometric figures. Since we will be initializing them in a random fashion, this process will be automatic and made by using *loops* .
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* This code is in your OpenCV sample folder. Otherwise you can grab it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/Basic/Drawing_2.cpp>`_ .
|
||||
* In the previous tutorial (:ref:`Drawing_1`) we drew diverse geometric figures, giving as input parameters such as coordinates (in the form of :point:`Points <>`), color, thickness, etc. You might have noticed that we gave specific values for these arguments.
|
||||
|
||||
* In this tutorial, we intend to use *random* values for the drawing parameters. Also, we intend to populate our image with a big number of geometric figures. Since we will be initializing them in a random fashion, this process will be automatic and made by using *loops* .
|
||||
|
||||
* This code is in your OpenCV sample folder. Otherwise you can grab it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/core/Matrix/Drawing_2.cpp>`_ .
|
||||
|
||||
Explanation
|
||||
============
|
||||
@ -172,6 +177,8 @@ Explanation
|
||||
|
||||
So, what does the function :put_text:`putText <>` do? In our example:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Draws the text **"Testing text rendering"** in **image**
|
||||
* The bottom-left corner of the text will be located in the Point **org**
|
||||
* The font type is a random integer value in the range: :math:`[0, 8>`.
|
||||
|
@ -17,7 +17,7 @@ In this tutorial you will learn how to:
|
||||
Source Code
|
||||
===========
|
||||
|
||||
Download the :download:`source code from here <../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp>` or look it up in our library at :file:`samples/cpp/tutorial_code/introduction/display_image/display_image.cpp`.
|
||||
Download the source code from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp>`_.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
@ -108,19 +108,21 @@ Because we want our window to be displayed until the user presses a key (otherwi
|
||||
Result
|
||||
=======
|
||||
|
||||
* Compile your code and then run the executable giving an image path as argument. If you're on Windows the executable will of course contain an *exe* extension too. Of course assure the image file is near your program file.
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Compile your code and then run the executable giving an image path as argument. If you're on Windows the executable will of course contain an *exe* extension too. Of course assure the image file is near your program file.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./DisplayImage HappyFish.jpg
|
||||
|
||||
* You should get a nice window as the one shown below:
|
||||
* You should get a nice window as the one shown below:
|
||||
|
||||
.. image:: images/Display_Image_Tutorial_Result.jpg
|
||||
:alt: Display Image Tutorial - Final Result
|
||||
:align: center
|
||||
|
||||
.. raw:: html
|
||||
.. raw:: html
|
||||
|
||||
<div align="center">
|
||||
<iframe title="Introduction - Display an Image" width="560" height="349" src="http://www.youtube.com/embed/1OJEqpuaGc4?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
|
@ -6,12 +6,14 @@ Using OpenCV with gcc and CMake
|
||||
.. note::
|
||||
We assume that you have successfully installed OpenCV in your workstation.
|
||||
|
||||
The easiest way of using OpenCV in your code is to use `CMake <http://www.cmake.org/>`_. A few advantages (taken from the Wiki):
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* No need to change anything when porting between Linux and Windows
|
||||
* Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
|
||||
* The easiest way of using OpenCV in your code is to use `CMake <http://www.cmake.org/>`_. A few advantages (taken from the Wiki):
|
||||
|
||||
If you are not familiar with CMake, checkout the `tutorial <http://www.cmake.org/cmake/help/cmake_tutorial.html>`_ on its website.
|
||||
#. No need to change anything when porting between Linux and Windows
|
||||
#. Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
|
||||
|
||||
* If you are not familiar with CMake, checkout the `tutorial <http://www.cmake.org/cmake/help/cmake_tutorial.html>`_ on its website.
|
||||
|
||||
Steps
|
||||
======
|
||||
|
Loading…
Reference in New Issue
Block a user