-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
54 lines (44 loc) · 1.59 KB
/
Copy pathrun.py
File metadata and controls
54 lines (44 loc) · 1.59 KB
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
46
47
48
49
50
51
52
53
54
from img_recog_numba import *
from img_recog_proto import *
from img_recog_proto import distort as protodistort
from puzzle_gui_chain import *
#from puzzle_gui_proto import *
from image_obj import *
from piecefinder import PieceFinder
from utils import *
import cv2
from dataset import *
from pathlib import Path
pool= 4
dims=(4,4)
brightness_delta=30
def open(path):
return openimg(path)
def split_shuffle(collection, dims):
return collection.shuffle_collection(dims)
def distort(collection, delta, mode):
return collection.distort_collection(delta, mode)
def solve(path, collection, pooling=5, method="xcorr", **params):
solutionimg=openimg(path)
dims, loss = find_dims(collection.average_shape(), len(collection), solutionimg.shape[0:2])
print("Shape loss: ", loss)
collection.dims=dims
id_slots = full_solve(collection, Solution(solutionimg, dims),
pooling=pooling, debug_mode=True, iterator_mode=False, id_only=True, method=method)
return id_slots
def detect(collection, threshold):
detector=PieceFinder(threshold=threshold)
image=collection.get()[0].array
boxes, scores = detector.find_boxes(image)
return boxes
def show(path):
image=cv2.imread(path)
cv2.imshow("Solution image", image)
cv2.waitKey(1)
"""genner=ImageSplitter()
genner.gen(Path("./tests/puzzle.jpg"), Path("./tests/samples/"), dims=dims, min =-1)
genner.close()
"""
#functions={"shuffle":split_shuffle, "solve":solve, "open":open, "distort":distort}
functions={"detect":detect, "solve":solve, "open":open, "distort":distort, "show":show}
root=GUI(functions)