OpenCV
4.1.0
Open Source Computer Vision
|
Next Tutorial: Random generator and text with OpenCV
In this tutorial you will learn how to:
For this tutorial, we will heavily use two structures: cv::Point and cv::Scalar :
It represents a 2D point, specified by its image coordinates \(x\) and \(y\). We can define it as:
or
For this tutorial, we will heavily use two structures: cv::Point and cv::Scalar :
It represents a 2D point, specified by its image coordinates \(x\) and \(y\). We can define it as:
or
Since we plan to draw two examples (an atom and a rook), we have to create two images and two windows to display them. [block]
We created functions to draw different geometric shapes. For instance, to draw the atom we used MyEllipse and MyFilledCircle: [block]
And to draw the rook we employed MyLine, rectangle and a MyPolygon: [block]
Let's check what is inside each of these functions: [block]
From the code above, we can observe that the function ellipse() draws an ellipse such that:
Similar to the ellipse function, we can observe that circle receives as arguments:
To draw a filled polygon we use the function fillPoly() . We note that:
Finally we have the cv::rectangle function (we did not create a special function for this guy). We note that:
Compiling and running your program should give you a result like this: