OpenCV  4.0.1
Open Source Computer Vision
Basic Drawing

Next Tutorial: Random generator and text with OpenCV

Goals

In this tutorial you will learn how to:

Code

Explanation

Since we plan to draw two examples (an atom and a rook), we have to create two images and two windows to display them.

We created functions to draw different geometric shapes. For instance, to draw the atom we used MyEllipse and MyFilledCircle:

And to draw the rook we employed MyLine, rectangle and a MyPolygon:

Let's check what is inside each of these functions:

MyLine

MyEllipse

MyFilledCircle

MyPolygon

rectangle

Result

Compiling and running your program should give you a result like this:

Drawing_1_Tutorial_Result_0.png