diff --git a/Image-Processing/Recogize_Text_From_Image/Recognize_text.md b/Image-Processing/Recogize_Text_From_Image/Recognize_text.md new file mode 100644 index 00000000..32cd38f0 --- /dev/null +++ b/Image-Processing/Recogize_Text_From_Image/Recognize_text.md @@ -0,0 +1,18 @@ +# Recognize Text From Image. +_LIBRARIES USED:_ + + pytesseract + cv2 + os + PIL +#### Installing tesseract + [You can download .exe file from here](https://github.com/UB-Mannheim/tesseract/wiki) + ```bash +Then you can provide the path +# path to the Tessaract +pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe" +``` +#### Installing cv2 module +```bash +pip install opencv-python +``` \ No newline at end of file diff --git a/Image-Processing/Recogize_Text_From_Image/Text_Recognizer.py b/Image-Processing/Recogize_Text_From_Image/Text_Recognizer.py new file mode 100644 index 00000000..e7c9ab55 --- /dev/null +++ b/Image-Processing/Recogize_Text_From_Image/Text_Recognizer.py @@ -0,0 +1,19 @@ +from PIL import Image +import pytesseract +import cv2 +import os + +# path to the Tessaract +pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe" + +image = cv2.imread("image.jpg") #read image +gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) #convert image into gray colored image +filename = "{}.jpg".format(os.getpid()) +cv2.imwrite(filename, gray) #write image into file +text = pytesseract.image_to_string(Image.open(filename)) #convert image into string and store in variable text +cv2.imshow("Image", image) +cv2.imshow("Output", gray) +cv2.waitKey(1) +print("successfully found") if 'NEVER' in text else print("Text Not Found") +os.remove(filename) + diff --git a/Image-Processing/Recogize_Text_From_Image/image.jpg b/Image-Processing/Recogize_Text_From_Image/image.jpg new file mode 100644 index 00000000..ac56e17f Binary files /dev/null and b/Image-Processing/Recogize_Text_From_Image/image.jpg differ