def scale(self):
self.original_image = self.image.copy()
self.image_height, self.image_width = self.image.shape[:2]
if max(self.image_width, self.image_height) > MAX_DIMENSION:
# Need to shrink
if self.image_width > self.image_height:
new_width = MAX_DIMENSION
new_height = int(self.image_height * new_width / self.image_width)
else:
new_height = MAX_DIMENSION
new_width = int(self.image_width * new_height / self.image_height)
print 'Resizing to {}x{}'.format(new_width, new_height)
self.image = cv2.resize(self.image, (new_width, new_height), interpolation=cv2.INTER_AREA)
self.image_height, self.image_width = self.image.shape[:2]
评论列表
文章目录