hello guys i'm working on my project with easy ocr for text detection i got some errors, but i don't know how to fix it, it will be greatful if someone can help me?
here's few errors i get
cv2.error: OpenCV(4.5.2) error: (-5:Bad argument) in function 'rectangle'
Overload resolution failed:
- Can't parse 'pt1'. Sequence item with index 0 has a wrong type
- Can't parse 'pt1'. Sequence item with index 0 has a wrong type
- Can't parse 'rec'. Expected sequence length 4, got 2
- Can't parse 'rec'. Expected sequence length 4, got 2
anyway this is my code
import cv2
import numpy as np
from matplotlib import pyplot as plt
import easyocr
cap = cv2.VideoCapture(0)
reader = easyocr.Reader(['en'], gpu = True)
while True :
_, frame = cap.read()
result = reader.readtext(frame)
for detection in result:
top_left = tuple(detection[0][0])
bottom_right = tuple(detection[0][2])
text = detection[1]
print (text)
img = cv2.rectangle(frame,top_left,bottom_right,(0,255,0),2)
cv2.imshow("Text Recognition", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
1条答案
按热度按时间svmlkihl1#
cv2.rectangle
需要int
值,而easyocr
可以返回浮点数。请尝试: