Refactoring

Move content rectangle base class
This commit is contained in:
Matthias Bisping 2023-02-01 13:19:25 +01:00
parent ba901473fe
commit 04a617b9df
4 changed files with 50 additions and 13 deletions

17
synthesis/__init__.py Normal file
View File

@ -0,0 +1,17 @@
import argparse
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument()
args = parser.parse_args()
return args
def main(args):
pass
if __name__ == "__main__":
main(parse_args())

View File

@ -0,0 +1,17 @@
import argparse
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument()
args = parser.parse_args()
return args
def main(args):
pass
if __name__ == "__main__":
main(parse_args())

View File

@ -0,0 +1,10 @@
from cv_analysis.utils.rectangle import Rectangle
class ContentRectangle(Rectangle):
def __init__(self, x1, y1, x2, y2, content=None):
super().__init__(x1, y1, x2, y2)
self.content = content
def __repr__(self):
return f"{self.__class__.__name__}({self.x1}, {self.y1}, {self.x2}, {self.y2}, content={self.content})"

View File

@ -27,11 +27,13 @@ from cv_analysis.utils.conversion import normalize_image_format_to_array, normal
from cv_analysis.utils.merging import merge_related_rectangles
from cv_analysis.utils.postprocessing import remove_overlapping, remove_included
from cv_analysis.utils.spacial import area
from synthesis.segment.content_rectangle import ContentRectangle
logger.remove()
logger.add(sys.stderr, level="INFO")
random_seed = random.randint(0, 2**32 - 1)
random_seed = 2973413116
rnd = random.Random(random_seed)
logger.info(f"Random seed: {random_seed}")
@ -391,12 +393,12 @@ def page_with_translucent_content(
@pytest.fixture
def page_with_content(
page_with_translucent_content,
# page_with_opaque_content,
# page_with_translucent_content,
page_with_opaque_content,
) -> np.ndarray:
page, boxes = page_with_translucent_content
# page, boxes = page_with_opaque_content
# page, boxes = page_with_translucent_content
page, boxes = page_with_opaque_content
draw_boxes(page, boxes)
@ -408,15 +410,6 @@ def to_array(image: Image) -> np.ndarray:
return np.array(image).astype(np.float32)
class ContentRectangle(Rectangle):
def __init__(self, x1, y1, x2, y2, content=None):
super().__init__(x1, y1, x2, y2)
self.content = content
def __repr__(self):
return f"{self.__class__.__name__}({self.x1}, {self.y1}, {self.x2}, {self.y2}, content={self.content})"
class ContentGenerator:
def __init__(self):
self.constrain_layouts = True