Fix: IndexError in OcrRogueWorld

This commit is contained in:
LmeSzinc 2024-02-13 01:22:35 +08:00
parent 4d64ec0252
commit 1bcef3071b

View File

@ -77,6 +77,8 @@ class OcrRogueWorld(Ocr):
center = color_similarity_2d(image, color=(255, 255, 255)) center = color_similarity_2d(image, color=(255, 255, 255))
cv2.inRange(center, 180, 255, dst=center) cv2.inRange(center, 180, 255, dst=center)
center = np.where(np.sum(center, axis=1) > 200)[0] center = np.where(np.sum(center, axis=1) > 200)[0]
if len(center) < 2:
return image
up, down = center[0], center[-1] up, down = center[0], center[-1]
image = image[up:down, :, :] image = image[up:down, :, :]
return image return image