refactoring
This commit is contained in:
parent
caef37376b
commit
1b1f1aafef
@ -12,6 +12,11 @@ from image_prediction.transformer.transformers.coordinate.fpdf import FPDFCoordi
|
|||||||
from image_prediction.transformer.transformers.coordinate.pdfnet import PDFNetCoordinateTransformer
|
from image_prediction.transformer.transformers.coordinate.pdfnet import PDFNetCoordinateTransformer
|
||||||
from test.conftest import array_to_image, add_image
|
from test.conftest import array_to_image, add_image
|
||||||
|
|
||||||
|
WIDTH = 200
|
||||||
|
HEIGHT = 100
|
||||||
|
PAGE_WIDTH = 300
|
||||||
|
PAGE_HEIGHT = 300
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("coordinate_system", ["fpdf"])
|
@pytest.mark.parametrize("coordinate_system", ["fpdf"])
|
||||||
def test_fpdf_coordinate_transformer(position_metadata_in_given_system, position_metadata_in_reference_system):
|
def test_fpdf_coordinate_transformer(position_metadata_in_given_system, position_metadata_in_reference_system):
|
||||||
@ -129,10 +134,10 @@ def get_fpdf_corner_metadat():
|
|||||||
+--(1,3) +--(3,3)
|
+--(1,3) +--(3,3)
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"top_left": get_metadata_for_coords(0, 0, 100, 100),
|
"top_left": get_metadata_for_coords(0, 0, WIDTH, HEIGHT),
|
||||||
"bottom_left": get_metadata_for_coords(0, 200, 100, 300),
|
"bottom_left": get_metadata_for_coords(0, PAGE_HEIGHT - HEIGHT, WIDTH, PAGE_HEIGHT),
|
||||||
"bottom_right": get_metadata_for_coords(200, 200, 300, 300),
|
"bottom_right": get_metadata_for_coords(PAGE_WIDTH - WIDTH, PAGE_HEIGHT - HEIGHT, PAGE_WIDTH, PAGE_HEIGHT),
|
||||||
"top_right": get_metadata_for_coords(200, 0, 300, 100)
|
"top_right": get_metadata_for_coords(PAGE_WIDTH - WIDTH, 0, PAGE_WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,10 +156,10 @@ def get_pdfnet_corner_metadata():
|
|||||||
(0,0)--+ (2,0)--+
|
(0,0)--+ (2,0)--+
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"top_left": get_metadata_for_coords(0, 200, 100, 300),
|
"top_left": get_metadata_for_coords(0, PAGE_HEIGHT - HEIGHT, WIDTH, PAGE_HEIGHT),
|
||||||
"bottom_left": get_metadata_for_coords(0, 0, 100, 100),
|
"bottom_left": get_metadata_for_coords(0, 0, WIDTH, HEIGHT),
|
||||||
"bottom_right": get_metadata_for_coords(200, 0, 300, 100),
|
"bottom_right": get_metadata_for_coords(PAGE_WIDTH - WIDTH, 0, PAGE_WIDTH, HEIGHT),
|
||||||
"top_right": get_metadata_for_coords(200, 200, 300, 300),
|
"top_right": get_metadata_for_coords(PAGE_WIDTH - WIDTH, PAGE_HEIGHT - HEIGHT, PAGE_WIDTH, PAGE_HEIGHT),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,17 +169,17 @@ def get_metadata_for_coords(x1, y1, x2, y2):
|
|||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
def base_position_metadata(width=100, height=100):
|
def base_position_metadata():
|
||||||
return {
|
return {
|
||||||
Info.X1: 0,
|
Info.X1: 0,
|
||||||
Info.Y1: 0,
|
Info.Y1: 0,
|
||||||
Info.X2: width,
|
Info.X2: WIDTH,
|
||||||
Info.Y2: height,
|
Info.Y2: HEIGHT,
|
||||||
Info.WIDTH: width,
|
Info.WIDTH: WIDTH,
|
||||||
Info.HEIGHT: height,
|
Info.HEIGHT: HEIGHT,
|
||||||
Info.PAGE_IDX: 0,
|
Info.PAGE_IDX: 0,
|
||||||
Info.PAGE_WIDTH: 300,
|
Info.PAGE_WIDTH: PAGE_WIDTH,
|
||||||
Info.PAGE_HEIGHT: 300,
|
Info.PAGE_HEIGHT: PAGE_HEIGHT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,11 +192,11 @@ def metadata_to_test_image(metadata):
|
|||||||
|
|
||||||
|
|
||||||
def get_coordinate_test_image():
|
def get_coordinate_test_image():
|
||||||
return array_to_image(np.zeros(shape=(100, 100, 3)))
|
return array_to_image(np.zeros(shape=(WIDTH, HEIGHT, 3)))
|
||||||
|
|
||||||
|
|
||||||
def get_coordinate_test_fpdf():
|
def get_coordinate_test_fpdf():
|
||||||
pdf = fpdf.FPDF(unit="pt", format=(300, 300))
|
pdf = fpdf.FPDF(unit="pt", format=(PAGE_WIDTH, PAGE_HEIGHT))
|
||||||
return pdf
|
return pdf
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user