OpenCV 5.0.0-pre
Open Source Computer Vision
|
Prev Tutorial: Basic Drawing
Next Tutorial: Smoothing Images
Original author | Ana Huamán |
Compatibility | OpenCV >= 3.0 |
In this tutorial you will learn how to:
Display_Random_Text:
Everything looks familiar but the expression:
So, what does the function cv::putText do? In our example:
As a result, we will get (analagously to the other drawing functions) NUMBER texts over our image, in random locations.
Displaying_Big_End
Besides the function getTextSize (which gets the size of the argument text), the new operation we can observe is inside the foor loop:
So, image2 is the subtraction of image and Scalar::all(i). In fact, what happens here is that every pixel of image2 will be the result of subtracting every pixel of image minus the value of i (remember that for each pixel we are considering three values such as R, G and B, so each of them will be affected)
Also remember that the subtraction operation always performs internally a saturate operation, which means that the result obtained will always be inside the allowed range (no negative and between 0 and 255 for our example).
As you just saw in the Code section, the program will sequentially execute diverse drawing functions, which will produce: