AWS Textract Bounding Box Visualization Context I have AWS Textract JSON output containing document analysis results with bounding box coordinates for text elements, tables, and other document components. I need to create a visualization tool that plots these bounding boxes on a coordinate system to understand the document layout. Task Create a Python script or web application that:
Parses the AWS Textract JSON containing:
Multiple blocks (PAGE, LINE, WORD, CELL, TABLE_TITLE, etc.) Each block has geometry data with BoundingBox and Polygon coordinates Coordinates are normalized (0-1 range) representing relative positions on the page
Visualizes the bounding boxes by:
Plotting rectangles for each bounding box on a canvas/plot Using different colors for different block types (LINE, WORD, CELL, etc.) Scaling coordinates appropriately for display Adding labels or hover information showing the text content and block type
Key coordinate system details:
BoundingBox format: {Width, Height, Left, Top} (all values 0-1) Polygon format: Array of {X, Y} points (all values 0-1) Origin (0,0) is at top-left corner Coordinates represent percentages of page dimensions
Sample JSON Structure json{ "Blocks": [ Â Â { Â Â Â Â "BlockType": "LINE", Â Â Â Â "Text": "ALMAC", Â Â Â Â "Geometry": { Â Â Â Â Â Â "BoundingBox": { Â Â Â Â Â Â Â Â "Width": 0.1078, Â Â Â Â Â Â Â Â "Height": 0.0156, Â Â Â Â Â Â Â Â "Left": 0.0603, Â Â Â Â Â Â Â Â "Top": 0.0629 Â Â Â Â Â Â }, Â Â Â Â Â Â "Polygon": [ Â Â Â Â Â Â Â Â {"X": 0.0603, "Y": 0.0629}, Â Â Â Â Â Â Â Â {"X": 0.1681, "Y": 0.0629}, Â Â Â Â Â Â Â Â {"X": 0.1681, "Y": 0.0785}, Â Â Â Â Â Â Â Â {"X": 0.0603, "Y": 0.0785} Â Â Â Â Â Â ] Â Â Â Â } Â Â } ] } Requirements
Option to toggle visibility of different block types Display text content when hovering over or clicking bounding boxes Scale the visualization to a reasonable size (e.g., 800x1000 pixels for a page) Handle the coordinate transformation from normalized (0-1) to pixel coordinates
Expected Output A tool that loads the Textract JSON and displays a visual representation of the document layout with all detected text regions, table cells, and other elements clearly outlined with their bounding boxes. Please create a complete, runnable solution with clear instructions for usage
I'll create a comprehensive AWS Textract bounding box visualization tool that can parse JSON output and display interactive visualizations of document layouts.
I've created a comprehensive AWS Textract bounding box visualization tool with the following features:
JSON Input Options:
Interactive Visualization:
Coordinate Handling:
Block Type Management:
The tool includes sample data that demonstrates various Textract block types including text lines, words, table cells, and page structure. You can immediately see how the visualization works by clicking "Load Sample Data".
User will be uploading a jpeg on top of it create bounding box
I'll enhance the AWS Textract visualization tool to support uploading a JPEG image and overlaying the bounding boxes directly on top of the document image. This will provide a much more intuitive way to verify Textract's detection accuracy.
I've enhanced the AWS Textract visualization tool with the following new capabilities:
Document Image Upload:
Image Overlay Visualization:
Sample Integration:
Enhanced User Experience:
This enhancement makes it much easier to:
The tool now provides a complete document analysis workflow, allowing you to overlay machine-detected regions directly onto the source document for immediate visual verification.
Convert the code in jsx and use some library instead of canvas