<jupyter_start><jupyter_text>OCR for Speed Recognition by Screen Capturing<jupyter_code>try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract

def ocr_core(filename):
    """
    This function will handle the core OCR processing of images.
    """
    text = pytesseract.image_to_string(Image.open(filename))  # We'll use Pillow's Image class to open the image and pytesseract to detect the string in the image
    return text

print(ocr_core('images/ocr_example_1.png'))
pytesseract.pytesseract.tesseract_cmd = r"C:\Users\mbura\AppData\Local\Tesseract-OCR\tesseract.exe"


fname = "C:/Users/mbura/Desktop/156.jpg"
image = Image.open(fname).convert("L")
img = np.asarray(image)
plt.imshow(arr, cmap='gray', vmin=0, vmax=255)
plt.show()
ret,img = cv2.threshold(np.array(img), 125, 255, cv2.THRESH_BINARY)
img = Image.fromarray(img.astype(np.uint8))
pytesseract.image_to_string(img, config='--psm 8')
%%timeit
pytesseract.image_to_string(img, config='--psm 8')
plt.imshow(img, cmap='gray', vmin=0, vmax=255)
plt.show()
pytesseract.image_to_string(img, config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')
plt.imshow(speed[:,:,2])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13810316139767054, 'fraction_numerical': 0.030782029950083195, 'mean_word_length': 5.6464088397790055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '526333', 'license': 'MIT', 'n_tokens_mistral': 495, 'n_tokens_neox': 469, 'n_words': 92, 'path': 'findROI_and_OCR.ipynb', 'repo_name': 'mburakbozbey/pycrew2', 'size': '1202'}