I was trying to make a script that reads numbers in a video and then converts them into x,y,z co ordinates

39 views Asked by At

but every time I run it it says "Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU." and then doesn't print anything ( I already have CUDA installed on my device ) I'm fine with using my cpu for easyocr but it isn't even printing anything

import cv2
import numpy as np
import easyocr
image_path = r"path"
img = cv2.imread(image_path)
if img is not None:
    reader = easyocr.Reader(['en'])
    results = reader.readtext(img)
    numbers = []
    for detection in results:
        text = detection[1]
        number = ''.join(filter(lambda x: x.isdigit() or x in ['.', '-'], text))
        if number:
            numbers.append(float(number))
    if numbers:
        X, Y, Z = numbers[:3]
        print(f"X = {X} Y = {Y} Z = {Z}")
    else:
        print("No valid numbers detected in the image.")
    cv2.imshow('Image', img)  # Show the image
    cv2.waitKey(0)
    cv2.destroyAllWindows()
else:
    print("Failed to load the image from the specified path.")

I haven't tried much since im pretty new to the easyocr module and idk how it works

0

There are 0 answers