OpenCV is the cross-platform open-source library for computer vision, image processing, and machine learning. It plays a major role nowadays in real-time operations in improving modules provides adequate functions for image manipulation. It has C++, C, Python, and Java interfaces and supports Windows, Linux, macOS, iOS, and Android. By using it, one can even process images and videos to identify objects, faces, or even handwriting of a human
Here, putText() which is an inbuilt method will be used after importing this method from its respective module given below in the java program.
Syntax: to import module to deal with images:
Syntax: to use putText() method of this class is as follows:
putText(image, text, org, fontType, fontSize, color, thickness)
|Datatype of parameters||Name of parameter||Functionalities|
|Mat object||image||Text to be added to an input image object|
|String||text||Text to be inserted to an input image|
|Point (tuple)||org||Coordinates of the bottom left corner of a text string in the image|
|Integer||fontType||Depicting the style of fonts|
|Double||fontSize||Size of text to be added over an input image|
|Scalar||color||Color of the text string to be drawn over an input image|
|Integer||thickness||The thickness of the line in the unit, by default it is unity|
Exception: No exception is thrown by this method of this class because simply the tuple is passed. For example in BGR color spectrum, the blue light tuple is as follows: (255,0,0)
Implementation: Input image is as follows been randomly taken. Now text- “GFG IS COOL” is to be added over this image.
Output: The image after adding text is as follows:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.