refactoring
This commit is contained in:
parent
57440f5106
commit
1bea5fb9a8
@ -10,7 +10,7 @@ from image_prediction.info import Info
|
||||
from image_prediction.stitching.grouping import CoordGrouper
|
||||
from image_prediction.stitching.utils import make_coord_getter, flatten_groups_once
|
||||
from image_prediction.utils.generic import until
|
||||
from test.utils.stitching import HorizontalSplitMapper, VerticalMapper
|
||||
from image_prediction.stitching.split_mapper import HorizontalSplitMapper, VerticalMapper
|
||||
|
||||
|
||||
def no_new_merges(pairs1, pairs2):
|
||||
|
||||
49
image_prediction/stitching/split_mapper.py
Normal file
49
image_prediction/stitching/split_mapper.py
Normal file
@ -0,0 +1,49 @@
|
||||
import abc
|
||||
|
||||
from image_prediction.info import Info
|
||||
|
||||
|
||||
class SplitMapper(abc.ABC):
|
||||
def __init__(self, wrapped: dict, keymap: dict):
|
||||
self.wrapped = wrapped
|
||||
self.keymap = keymap
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.wrapped[self.keymap[key]]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.wrapped[self.keymap[key]] = value
|
||||
|
||||
@property
|
||||
def dim(self):
|
||||
return self["dim"]
|
||||
|
||||
@dim.setter
|
||||
def dim(self, value):
|
||||
self["dim"] = value
|
||||
|
||||
@property
|
||||
def c1(self):
|
||||
return self["c1"]
|
||||
|
||||
@c1.setter
|
||||
def c1(self, value):
|
||||
self["c1"] = value
|
||||
|
||||
@property
|
||||
def c2(self):
|
||||
return self["c2"]
|
||||
|
||||
@c2.setter
|
||||
def c2(self, value):
|
||||
self["c2"] = value
|
||||
|
||||
|
||||
class HorizontalSplitMapper(SplitMapper):
|
||||
def __init__(self, wrapped: dict):
|
||||
super().__init__(wrapped, {"dim": Info.WIDTH, "c1": Info.X1, "c2": Info.X2})
|
||||
|
||||
|
||||
class VerticalMapper(SplitMapper):
|
||||
def __init__(self, wrapped: dict):
|
||||
super().__init__(wrapped, {"dim": Info.HEIGHT, "c1": Info.Y1, "c2": Info.Y2})
|
||||
@ -1,57 +1,10 @@
|
||||
import abc
|
||||
import random
|
||||
from copy import deepcopy
|
||||
from itertools import chain
|
||||
|
||||
from funcy import rpartial, juxt
|
||||
|
||||
from image_prediction.info import Info
|
||||
|
||||
|
||||
class SplitMapper(abc.ABC):
|
||||
def __init__(self, wrapped: dict, keymap: dict):
|
||||
self.wrapped = wrapped
|
||||
self.keymap = keymap
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.wrapped[self.keymap[key]]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.wrapped[self.keymap[key]] = value
|
||||
|
||||
@property
|
||||
def dim(self):
|
||||
return self["dim"]
|
||||
|
||||
@dim.setter
|
||||
def dim(self, value):
|
||||
self["dim"] = value
|
||||
|
||||
@property
|
||||
def c1(self):
|
||||
return self["c1"]
|
||||
|
||||
@c1.setter
|
||||
def c1(self, value):
|
||||
self["c1"] = value
|
||||
|
||||
@property
|
||||
def c2(self):
|
||||
return self["c2"]
|
||||
|
||||
@c2.setter
|
||||
def c2(self, value):
|
||||
self["c2"] = value
|
||||
|
||||
|
||||
class HorizontalSplitMapper(SplitMapper):
|
||||
def __init__(self, wrapped: dict):
|
||||
super().__init__(wrapped, {"dim": Info.WIDTH, "c1": Info.X1, "c2": Info.X2})
|
||||
|
||||
|
||||
class VerticalMapper(SplitMapper):
|
||||
def __init__(self, wrapped: dict):
|
||||
super().__init__(wrapped, {"dim": Info.HEIGHT, "c1": Info.Y1, "c2": Info.Y2})
|
||||
from image_prediction.stitching.split_mapper import SplitMapper, HorizontalSplitMapper, VerticalMapper
|
||||
|
||||
|
||||
class BoxSplitter:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user