I'm trying to run the paddleOCR framework on the cropped ROI of a scanned image, but when I do, I always get the error message mentioned below. I have no idea what's gone wrong.
UFuncTypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_37324\165684197.py in <module>
1
----> 2 save_ocr(img_path, out_path, result2, font)
~\AppData\Local\Temp\ipykernel_37324\1042196559.py in save_ocr(img_path, out_path, result, font)
1
2 def save_ocr(img_path, out_path, result, font):
----> 3 save_path = os.path.join(out_path, img_path + '-output.jpg')
4
5 image = cv2.imread(img_path)
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U11'), dtype('<U11')) -> dtype('<U11')
What I have tried:
import cv2
inp = '.../inputimg.jpg'
image2 = cv2.imread(inp)
x,y,w,h = x1,y1,w1,h1
ROI3 = image2[y:y+h, x:x+w]
cv2.imshow('cropped for treatment', ROI3)
cv2.waitKey(0)
cv2.destroyAllWindows()
img_path = ROI3
out_path = '----/output_images'
font = '---/simfang.ttf'
result2 = ocr.ocr(img_path)
def save_ocr(img_path, out_path, result, font):
save_path = os.path.join(out_path, img_path + '-output.jpg')
image = cv2.imread(img_path)
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path=font)
cv2.imwrite(save_path, im_show)
img = cv2.cvtColor(im_show, cv2.COLOR_BGR2RGB)
plt.imshow(img)
save_ocr(img_path, out_path, result2, font)
What am I doing wrong as I cannot save and display the final result?