jasonlfunk / ocr-text-extraction Goto Github PK
View Code? Open in Web Editor NEWA simple program to extract the text from an image before performing OCR
License: MIT License
A simple program to extract the text from an image before performing OCR
License: MIT License
For whatever reason, cv2.findContours
on line 211 returns three arguments instead of the expected 2. From playing with it, I found that by eliminating the first value would solve the problem.
I am not knowledgeable about cv2 so if this is something obvious someone please say so. (MacOS, cv2 '3.2.0').
Here is the fix that worked for me.
result = cv2.findContours(edges.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
contours, hierarchy = result if len(result) == 2 else result[1:3]
in extract_bv(image)
22 ret,f6 = cv2.threshold(f5,15,255,cv2.THRESH_BINARY)
23 mask = np.ones(f5.shape[:2], dtype="uint8") * 255
---> 24 image, contours, hierarchy = cv2.findContours(f6.copy() ,cv2.RETR_LIST ,cv2.CHAIN_APPROX_SIMPLE)
25 for cnt in contours:
26 if cv2.contourArea(cnt) <= 200:
ValueError: not enough values to unpack (expected 3, got 2)
Unable to resolve this error :
TypeError Traceback (most recent call last)
in
207 X,label=shuffle(X,label,random_state=2)
208 model=get_model()
--> 209 fit_model(model,X,label)
in fit_model(model, X, label)
189
190 datagen.fit(X_train)
--> 191 model.fit_generator(datagen.flow(X_train, y_train, batch_size=32, class_mode="categorical",target_size=(64, 64),color_mode="rgb",save_to_dir=r'/Users/Sanjeeth/Python work space/project1/testing/resnet/', save_prefix='fudus', save_format='jpeg'), steps_per_epoch=len(X_train) / 32, epochs=4)
192
193
Is there any option to set a threshold on how we color the image? I have a file with white-on-black and black-on-white text. The script does a phenomenal job detecting the white-on-black text and converting it. However, it also erroneously inverts many of the black-on-white texts. Is that something that could potentially be tuned and fixed by giving us some parameter options?
This is a great effort and some tweaking it could be very useful for tesseract OCR.
the problem right now is that resulting text seems almost like it's from an withering ancient book. For example "O" looks almost like "U".
the best way I can put it is texts look almost dirty.
what variables or configs can I alter to retain the clean cut text like shown in the answer at
How about the word?
Hi @jasonlfunk,
It's a great repo which done decent job on most of the images, I observed that for some color images , it will make black bounding box(inside this text is present), may happen due to size of contour , instead of ((img_x * img_y) / 5) this if I set it to fixed number i.e 10,000(250dpi img) above problem were solved but if text height(colour heading) exceed above threshold and it will not make correct thresholding of that portion
Please let me know is there any robust way to solve above issue.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.