OpenCV tesseract not detect single digit number in an image
I am using tesseract with python. It recognizes almost all of my images with 2 or more numbers or characters
I don't want to train tesseract with "only digits" because I am recognizing characters too.
But the attached image is not recognized from tessearact
still am not able to read the text from the image..any help much appreciated
See also questions close to this topic
how to convert comma seperated values to integer in pandas
I have following dataframe in pandas.
order_id no 1 1,234,450,445.00 2 1,234,450,446.00 3 1,234,450,447.00
I want to convert the no column to integer. Following is my desired dataframe.
order_id no 1 1234450445 2 1234450446 3 1234450447
When I do dtypes, it shows as
I tried following
df['no'] = (pd.to_numeric(df['no'].str.replace(',',''), errors='coerce'))
How can I convert this to integer in pandas?
How to read excel in python from user input
I have an excel file that looks like this:
Bob | 15
Joe | 25
Tim | 19
I'm trying to write a code so that if the user inputs the name bob, it will print 15.. or if the user inputs Joe, it will print 25 etc
I can't figure out how to get python to read an input string and match it to the cell in excel
Flask SQLAlchemy: How to find the primary key value before adding a new object to the session?
b64encodeto create a unique reference string from the primary key in each row in the table. This is my model in Flask SQLAlchemy:
class Groups(db.Model): id = db.Column(db.Integer, primary_key = True) ref_id = db.Column(db.String(20), index = True) def __init__(self): self.ref_id = id_encode(self.id)
self.idpassed into the
id_encode()function has a "None" value instead of the primary key's value. From what I can see, it's only possible to get the new primary key value after committing the session, or by using the flush() method.
Here's the definition for
def id_encode(num): bts = base64.b64encode(bytes(str(num), 'utf-8')) print(num) return bts.decode()
If there any way to get this to work, or what's a better (but simple) way to do unique reference ID generation? I just don't want the average user to be able to navigate to other groups by entering a numeric ID.
EmguCV with Tesseract OCR fails to recognize even binary black-white single character images
I am trying to get OCR working with Tesseract using EmguCV .NET wrapper. Because it didn’t recognize what seems to be very simple cases I went ahead and downloaded the command line tool itself here and confirmed it acted the same way as the Emgu wrapper so it is not the library’s fault, it seems to be the way I use it or the tesseract itself. I got the eng.traineddata from the official tesseract installation binary from the link above as well.
tesseract v5.0.0-alpha.20200328 leptonica-1.78.0
My code sample:
var testBitmap = Screenshot.MakeCroppedBitmap(LeftPoint, ScreenshotSize); // takes partial screenshot Tesseract ocr = new Tesseract(Tesseract.DefaultTesseractDirectory, "eng", OcrEngineMode.Default); ocr.PageSegMode = PageSegMode.SingleChar; Image<Bgr, byte> emguImageOCR = testBitmap.ToImage<Bgr, byte>(); Image<Gray, byte> emguImageOCRGray = emguImageOCR.Convert<Gray, byte>(); emguImageOCRGray._ThresholdBinary(new Gray(235), new Gray(255)); ocr.SetImage(emguImageOCRGray); ocr.Recognize(); Console.WriteLine(ocr.GetUTF8Text()); emguImageOCRGray.Save("this-is-what-I-tried-to-read.png"); testBitmap.Dispose(); emguImageOCR.Dispose(); emguImageOCRGray.Dispose();
Those are just 2 examples. It also makes mistakes for full sentences, but not always. Some cases were correct. What am I doing wrong here? This has to be my fault, there is no way I am using this right.
how to get automatically segregate the products, item, qty, price fields explicitly, and fetch it from "Invoice image" Cloud Vision OCR data?
We are facing a few challenges in getting the exact data from the "Invoice Bill" Image. Using Machine Learning, we are trying to split the Invoice bill image converted (OCR) to text data such as purchased items, date, title, address, etc., We have multiple invoice formats of companies or business entities.
How can we classify the text which we get from the bill (image) converted Text?, also how to train the Machine Learning system to automatically segregate the products, item, qty, price fields explicitly, and fetch it?
"Cannot add tensor to the batch: number of elements does not match" while iterating through tensor
I fed my data to train_dataset like this. I noted the line where I had the error:
batch_size = 30 train_dataset = tf.data.Dataset.from_tensor_slices((x_train, y_train)) train_dataset = ( train_dataset.map(encode_single_sample, num_parallel_calls=tf.data.experimental.AUTOTUNE) .batch(batch_size) <- this one has problem .prefetch(buffer_size=tf.data.experimental.AUTOTUNE))
I get a InvalidArgumentError: Cannot add tensor to the batch: number of elements does not match. Shapes are: [tensor]: , [batch]:  when I iterate through the dataset:
for batch in train_dataset.take(1): #this line gives the error
I noticed that the [tensor] and [batch] numbers in the error message change every time I run the code again. Would appreciate it if anyone could debug this part for me ;-;
Edit 1: I'm following Keras' OCR tutorial here, and I run their code just fine. I changed my input shape to 800x64.
pytesseract image_to_string function giving a complete unrelated output
I'm trying to extract text from an image but pytesseract is giving a totally different output, the image attached below output is "Werle" (complete different word and characters), I tried many different processing methods like image enhancement, rgb2gray, rgb2binary, still didn't work. What confuses me that the text in the image is very clear and straightforward. I also tried to change the notebook from google colab to my local notebook and checked the library version, but same incorrect result.
output >> "Werle"
here's my code:-
ret,frame = cap.read() crop_img = frame[320:400,430:840] text = pt.image_to_string(crop_img)
note: this problem happens with other images with the same style but different word
How to ignore special characters in Tesseract OCR?
Pretty much the title.
Is there any way for tesseract to read only alphabetical characters? I guess one option would to use
tessedit_char_whitelist. Is there any other way like specifying range
[a-z]or something else?