Quote (Candyzcanes @ Dec 14 2023 05:57pm)
i've tried using tesseract ocr on many things that are very legible and i struggled greatly.
if you are using python this is what i got to sort of work
Code
import cv2
import pytesseract
import matplotlib.pyplot as plt
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
img = cv2.imread('resources/ammy.png')
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
text = pytesseract.image_to_string(img)
spl_text = text.split("\n")
spl_text_two = ''
for sentence in spl_text:
spl_text_two.join(sentence.split())
print('spltwo' + spl_text_two)
for i in range(len(spl_text)+1):
for word in spl_text_two:
print(word)
print(str(i) + " " + spl_text[i])
this converted
https://i.imgur.com/gS5aS3C.pngto
DEATH ToRC
AMULET
ReguirReD LeveL: 52
+2 To LIGHTNING SKILLs (S@RcERESS ONLY)
*19% FASTER CAST RATE
+17 Te MANA
REGENERATE MANA 10%
CoLpD Resist +6%
LIGHTNING RESIST 9 6%
Fire Resist + 6%
P@IseN Resist: + 35%
...almost..lol
yeah i can't get a better output than that, i tried preprocessing the image and stuff but the result was basically the same when i did your ammy
i've never used ocr and it just kinda sucks ass at some fonts. training it with the font data is way outside the scope of my project. can't believe it won't read mine honestly. other OCRs i know of are cloud based and i think you gotta pay
i'm kinda stumped
Code
import cv2
import pytesseract
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
# Set the Tesseract OCR executable path
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
# Read the image using OpenCV
img = cv2.imread('LINKTOIMAGE')
# Convert the image to grayscale
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Use pytesseract to extract text from the image
text = pytesseract.image_to_string(gray_img)
# Split the text into lines
spl_text = text.split("\n")
# Initialize an empty string to store the modified text
spl_text_two = ''
# Concatenate words without spaces to remove line breaks
for sentence in spl_text:
spl_text_two += ''.join(sentence.split())
# Convert the text to title case
spl_text_two = spl_text_two.title()
# Print the modified text
print('spl_text_two: ' + spl_text_two)
# Print each word and its corresponding line number
for i, word in enumerate(spl_text):
print(f'{i + 1}: {word.title()}')
The OutputDeathtorcamuletreguirredlevel:52+2T®Lightningskills(S@Rceressonly}*19%Fastercastrate+17Temanaregeneratemana10%Coltdresist-+6%Lightningaresistyp6%Fireresist+6%Poisonoresist:+35%
1: Death Torc
2: Amulet
3: Reguirred Level: 52
4: +2 T® Lightning Skills (S@Rceress Only}
5: *19% Faster Cast Rate
6: +17 Te Mana
7: Regenerate Mana 10%
8: Coltd Resist-+6%
9: Lightningaresist Yp 6%
10: Fire Resist + 6%
11: Poisono Resist: + 35%
This post was edited by bLink11 on Dec 14 2023 06:12pm