def get_current_page(self, img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
area = crop_image(img, **self.predefined.page_area)
area = mask_image([254], [255], area)
height, width = area.shape
current_page = 0
for x in range(4):
box = crop_image(area, (x * width / 4), 0, ((x + 1) * width / 4), height)
if cv2.countNonZero(box) > 0:
current_page = x
break
return current_page + 1
评论列表
文章目录