@ -21,15 +21,22 @@ In this tutorial you will learn how to:
- Draw a **circle** by using the OpenCV function **circle()**
- Draw a **circle** by using the OpenCV function **circle()**
- Draw a **filled polygon** by using the OpenCV function **fillPoly()**
- Draw a **filled polygon** by using the OpenCV function **fillPoly()**
@add_toggle_cpp
OpenCV Theory
OpenCV Theory
-------------
-------------
@add_toggle_cpp
For this tutorial, we will heavily use two structures: @ref cv::Point and @ref cv::Scalar :
@end_toggle
@add_toggle_java
For this tutorial, we will heavily use two structures: @ref cv::Point and @ref cv::Scalar :
For this tutorial, we will heavily use two structures: @ref cv::Point and @ref cv::Scalar :
@end_toggle
@add_toggle_python
For this tutorial, we will heavily use tuples in Python instead of @ref cv::Point and @ref cv::Scalar :
@end_toggle
### Point
### Point
It represents a 2D point, specified by its image coordinates \f$x\f$ and \f$y\f$. We can define it as:
It represents a 2D point, specified by its image coordinates \f$x\f$ and \f$y\f$. We can define it as:
@add_toggle_cpp
@code {.cpp}
@code {.cpp}
Point pt;
Point pt;
pt.x = 10;
pt.x = 10;
@ -39,28 +46,8 @@ or
@code {.cpp}
@code {.cpp}
Point pt = Point(10, 8);
Point pt = Point(10, 8);
@endcode
@endcode
### Scalar
- Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel
values.
- In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is
not necessary to define the last argument if it is not going to be used.
- Let's see an example, if we are asked for a color argument and we give:
@code {.cpp}
Scalar( a, b, c )
@endcode
We would be defining a BGR color such as: *Blue = a* , *Green = b* and *Red = c*
@end_toggle
@end_toggle
@add_toggle_java
@add_toggle_java
OpenCV Theory
-------------
For this tutorial, we will heavily use two structures: @ref cv::Point and @ref cv::Scalar :
### Point
It represents a 2D point, specified by its image coordinates \f$x\f$ and \f$y\f$. We can define it as:
@code {.java}
@code {.java}
Point pt = new Point();
Point pt = new Point();
pt.x = 10;
pt.x = 10;
@ -70,6 +57,12 @@ or
@code {.java}
@code {.java}
Point pt = new Point(10, 8);
Point pt = new Point(10, 8);
@endcode
@endcode
@end_toggle
@add_toggle_python
@code {.python}
pt = (10, 0) # x = 10, y = 0
@endcode
@end_toggle
### Scalar
### Scalar
- Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel
- Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel
@ -77,11 +70,22 @@ Point pt = new Point(10, 8);
- In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is
- In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is
not necessary to define the last argument if it is not going to be used.
not necessary to define the last argument if it is not going to be used.
- Let's see an example, if we are asked for a color argument and we give:
- Let's see an example, if we are asked for a color argument and we give:
@add_toggle_cpp
@code {.cpp}
Scalar( a, b, c )
@endcode
@end_toggle
@add_toggle_java
@code {.java}
@code {.java}
Scalar( a, b, c )
Scalar( a, b, c )
@endcode
@endcode
We would be defining a BGR color such as: *Blue = a* , *Green = b* and *Red = c*
@end_toggle
@end_toggle
@add_toggle_python
@code {.python}
( a, b, c )
@endcode
@end_toggle
We would be defining a BGR color such as: *Blue = a* , *Green = b* and *Red = c*
Code
Code
----
----