Refactoring
Move content rectangle base class
This commit is contained in:
parent
ba901473fe
commit
04a617b9df
17
synthesis/__init__.py
Normal file
17
synthesis/__init__.py
Normal 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())
|
||||
17
synthesis/segment/__init__.py
Normal file
17
synthesis/segment/__init__.py
Normal 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())
|
||||
10
synthesis/segment/content_rectangle.py
Normal file
10
synthesis/segment/content_rectangle.py
Normal 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})"
|
||||
19
test/fixtures/page_generation/page.py
vendored
19
test/fixtures/page_generation/page.py
vendored
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user