feat: add log for export api
This commit is contained in:
35
tests/tools/layout.py
Normal file
35
tests/tools/layout.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import cv2
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.services.layout_detector import LayoutDetector
|
||||
|
||||
settings = get_settings()
|
||||
|
||||
|
||||
def debug_layout_detector():
|
||||
layout_detector = LayoutDetector()
|
||||
image = cv2.imread("test/image2.png")
|
||||
|
||||
print(f"Image shape: {image.shape}")
|
||||
|
||||
# padded_image = ImageProcessor(padding_ratio=0.15).add_padding(image)
|
||||
layout_info = layout_detector.detect(image)
|
||||
|
||||
# draw the layout info and label
|
||||
for region in layout_info.regions:
|
||||
x1, y1, x2, y2 = region.bbox
|
||||
cv2.putText(
|
||||
image,
|
||||
region.native_label,
|
||||
(int(x1), int(y1)),
|
||||
cv2.FONT_HERSHEY_SIMPLEX,
|
||||
0.5,
|
||||
(0, 0, 255),
|
||||
2,
|
||||
)
|
||||
cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), (0, 0, 255), 2)
|
||||
cv2.imwrite("test/layout_debug.png", image)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug_layout_detector()
|
||||
Reference in New Issue
Block a user