Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have this code below, it works on some images for cropping sub-images for every word in the image contains text. Some images raised an issue while cropping them, I could not find the reason and solution for the error, please help. the error:

SystemError: tile cannot extend outside image

the code:

IMAGE_PATH = '005002006002-1.tiff'
conv = cv2.imread(IMAGE_PATH)
reader = easyocr.Reader(['ar'],gpu=True)
result = reader.readtext(conv)

img = cv2.imread(IMAGE_PATH)
Image_number = 1000
copy = img.copy()
for i in result:
    top_left = tuple([int(val) for val in i[0][0]])
    bottom_right = tuple([int(val) for val in i[0][2]])
    img = cv2.rectangle(copy, top_left, bottom_right, (36,255,12), 3)
    cropped_img = img[top_left[1]:bottom_right[1], top_left[0]:bottom_right[0], :] 
    plt.imsave('newsub/005002006002-1_{}.tiff'.format(Image_number), cropped_img )
    Image_number += 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...