Text Detection and Extraction using OpenCV and OCR
Text Detection and Extraction using OpenCV and OCR Applying OCR: Loop through each contour and take the x and y coordinates and the width and height using the function cv2.boundingRect() . Then draw a rectangle in the image using the function cv2.rectangle() with the help of obtained x and y coordinates and the width and height. There are 5 parameters in the cv2.rectangle(), the first parameter specifies the input image, followed by the x and y coordinates (starting coordinates of the rectangle), the ending coordinates of the rectangle which is (x+w, y+h), the boundary color for the rectangle in RGB value and the size of the boundary. Now crop the rectangular region and then pass it to the tesseract to extract the text from the image. Then we open the created text file in append mode to append the obtained text and close the file Finding Contours: cv2.findContours() is used to find contours in the dilated image. There are three arguments in cv.findContours(): the source image, the