Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9f660aa

Browse files
Required Changes have been made.
1 parent c0743a1 commit 9f660aa

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

‎Realtime Text Extraction/Realtime Text Extraction.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
'''
2-
For using this code your machine had already installed OpenCV, pytesseract and PIL.
3-
For capturing a image press 'SPACE' when web-cam is on.
4-
'''
51
#importing required libraries
62

73
import cv2
84
import pytesseract
95
from PIL import Image
106

117
#Put the path where you stored the tesseract.exe file in your machine
12-
pytesseract.pytesseract.tesseract_cmd = r"C:\Users91769円\AppData\Local\Programs\Tesseract-OCR\tesseract.exe"
8+
pytesseract_file=input("Enter the path where you stored the tesseract.exe file\n")
9+
pytesseract.pytesseract.tesseract_cmd = pytesseract_file
1310

1411

1512
cam = cv2.VideoCapture(0) #Starting your webcam
1613

1714
while True:
1815
ret, img = cam.read() #Capturing the image
19-
#img= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) Can convert colour image to grayscale
16+
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #Can convert colour image to grayscale
2017

2118
cv2.imshow("Original",img)
2219
#Removing noise from the image
23-
ret, thresh = cv2.threshold(img,1010, 200, cv2.THRESH_OTSU, cv2.THRESH_BINARY)
20+
ret, thresh = cv2.threshold(gray,1010, 200, cv2.THRESH_OTSU, cv2.THRESH_BINARY)
2421
cv2.imshow("After removing noise", thresh)
2522

2623
if not ret:
@@ -37,11 +34,12 @@
3734
#For Space key
3835
print("Image saved")
3936
#Put the path where you want to store the captured image in your machine
40-
path=r'C:\Users91769円\Desktop\images'+'\img.jpg'
37+
path=input("Enter the path where you want to store the image\n ")
38+
path=path+'\img.jpg'
4139
cv2.imwrite(path, thresh)
4240
break
4341

44-
src= Image.open(r"C:\Users91769円\Desktop\images\img.jpg")
42+
src= Image.open(path)
4543

4644
text= pytesseract.image_to_string(src) #Extracting the text from image
4745
print(text)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /