-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageController.py
32 lines (25 loc) · 939 Bytes
/
ImageController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import cv2
"""
class used to control the image
"""
class image_controller:
image = None
image_original = None
def __init__(self, i_image):
self.image = i_image
self.image_original = i_image
def rotate(self, angle):
M = cv2.getRotationMatrix2D((self.image.shape[1]/2, self.image.shape[0]/2), angle, 1)
self.image = cv2.warpAffine(self.image, M, (self.image.shape[1], self.image.shape[0]))
def reset(self):
self.image = self.image_original
def show(self):
cv2.imshow('control this image!', self.image)
def resize_horizontal(self):
height = self.image.shape[0]
width = round(self.image.shape[1] * 0.99)
self.image = cv2.resize(self.image, (width, height))
def resize_vertical(self):
width = self.image.shape[1]
height = round(self.image.shape[0] * 0.99)
self.image = cv2.resize(self.image, (width, height))