coordinate transformer wip
This commit is contained in:
parent
9663cec12d
commit
3d2c97bc10
@ -5,6 +5,7 @@ from pdf2image import pdf2image
|
||||
|
||||
from image_prediction.image_extractor.extractor import ImageMetadataPair
|
||||
from image_prediction.info import Info
|
||||
from image_prediction.transformer.transformers.coordinate.fpdf import FPDFCoordinateTransformer
|
||||
from test.conftest import array_to_image, add_image
|
||||
|
||||
|
||||
@ -19,9 +20,8 @@ def coordinate_test_fpdf():
|
||||
return pdf
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def position_metadata(corner):
|
||||
metadata = {Info.X1: 0, Info.Y1: 0, Info.WIDTH: 100, Info.HEIGHT: 100, Info.PAGE_IDX: 0}
|
||||
def get_fpdf_coordinates(corner):
|
||||
metadata = base_position_metadata()
|
||||
|
||||
if corner == "top left":
|
||||
metadata.update({Info.X1: 0, Info.Y1: 0})
|
||||
@ -32,6 +32,16 @@ def position_metadata(corner):
|
||||
return metadata
|
||||
|
||||
|
||||
def base_position_metadata():
|
||||
return {Info.X1: 0, Info.Y1: 0, Info.WIDTH: 100, Info.HEIGHT: 100, Info.PAGE_IDX: 0}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def position_metadata(corner, coordinate_system):
|
||||
if coordinate_system == "fpdf":
|
||||
return get_fpdf_coordinates(corner)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def coordinate_test_pdf(position_metadata, coordinate_test_image, coordinate_test_fpdf):
|
||||
add_image(coordinate_test_fpdf, ImageMetadataPair(coordinate_test_image, position_metadata))
|
||||
@ -44,8 +54,8 @@ def coordinate_test_page_image(coordinate_test_pdf):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("corner", ["top left", "bottom left"])
|
||||
@pytest.mark.parametrize("coordinate_system", ["fpdf"])
|
||||
def test_coordinate_transformer(position_metadata, coordinate_test_page_image):
|
||||
# coordinate_test_pdf.output("/tmp/x.pdf")
|
||||
# coordinate_test_page_image.show()
|
||||
|
||||
|
||||
assert FPDFCoordinateTransformer()(position_metadata) == position_metadata
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user