forked from breezykermo/hue-hug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest0.py
45 lines (35 loc) · 1.03 KB
/
test0.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
33
34
35
36
37
38
39
40
41
42
43
44
45
import json
import cv2
import matplotlib.pyplot as plt
import numpy as np
from src.processor.cutter import ClairesCutter
from src.processor.image import ClairesImage
class Printer:
__single = None
__i = 0
__plt = plt
# Making printer a singleton
def __init__(self):
self.__plt.figure()
if Printer.__single:
raise Printer.__single
Printer.__single = self
def add(self, image, title):
self.__i = self.__i + 1
self.__plt.subplot(3, 2, self.__i)
self.__plt.imshow(image)
self.__plt.title(title)
def show(self):
self.__plt.show()
printer = Printer()
with open('test/one-red-hi-there.json') as dataFile:
jsonData = json.load(dataFile)
cutter = ClairesCutter(jsonData['image'], 'base64')
printer.add(cutter.getOriginal().getOpenCV(), 'Original')
positions = cutter.getPositions()
cutter.restoreImage()
images = []
for color in positions:
for position in positions[color]:
printer.add(cutter.crop(position), color)
printer.show()