def get_word_image(self, gray_scale=True):
col_type = None
if gray_scale:
col_type = cv2.CV_LOAD_IMAGE_GRAYSCALE
else:
col_type = cv2.CV_LOAD_IMAGE_COLOR
# load the image
ul = self.bounding_box['upperLeft']
wh = self.bounding_box['widthHeight']
img = cv2.imread(self.image_path, col_type)
if not np.all(self.bounding_box['widthHeight'] == -1):
img = img[ul[1]:ul[1]+wh[1], ul[0]:ul[0]+wh[0]]
return img
评论列表
文章目录