
Optical character recognition, also known as OCR, recognizes text in images.
#Opencv text on image install
We need to install and import our dependencies.You can view EDUCBA’s recommended articles for more information. We hope that this EDUCBA information on “OpenCV text” was beneficial to you. The output is shown in the snapshot above. Then we are displaying the resulting image with text written on it as the output on the screen. Then we are using the putText() function to write the text on the image by specifying all the parameters. Then we are storing the position of the text on the image along the horizontal and vertical axes in a variable. Then we are reading the image on which the text is supposed to be written using the imread() function from the cv2 module. In the above program, we are importing the module cv2. Imagewrite = cv2.imread('C:/Users/admin/Desktop/tree.jpg', cv2.IMREAD_UNCHANGED) Imagewrite = cv2.imread('C:/Users/admin/Desktop/plane.jpg', cv2.IMREAD_UNCHANGED)

#displaying the resulting image as the output on the screenĬv2.imwrite("C:/Users/admin/Desktop/logo1.png", imagewrite) #specifying the thickness of the font line in the text #specifying the position of the text on the image #specifying the text to be written on the image #specifying the image on which text must be written #using putText() function to write the text on the image #storing the position of the text on the image along the horizontal and vertical axes in a variable Imagewrite = cv2.imread('C:/Users/admin/Desktop/logo.png', cv2.IMREAD_UNCHANGED)

#reading the image on which the text is to be written using imread() function OpenCV program in python to demonstrate putText() function using which we are going to write a text on the image and display the image with text written on it as the output on the screen: Here are the following examples mention below Example #1 The putText() function returns an image with text written on it.Some of the font types of the text to be written on the image are FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, etc.The putText() function in OpenCV is very much essential in solving computer vision problems.Whenever there is a necessity to write text on an image, we make use of a function called the putText() function in OpenCV.Thickness is the thickness of the font line in the text. Position is the position of the text on the image along the horizontal and vertical axes, Text is the text that is supposed to be written on the image, Where image is the image on which the text is supposed to be written,

Cv2.putText(image, text, position, textfont, fontsize, fontcolor, thickness)
