A Python-based 3D geometry system that reads raw .obj mesh files, extracts vertex data, applies Principal Component Analysis (PCA) to determine object orientation, computes a tight Oriented Bounding Box (OBB), and visually validates dimensions and volume using Open3D.
- Overview
- Features
- Folder Structure
- How to Run Locally
- System Flow & Design Decisions
- Geometry Processing Pipeline
- Mermaid Flow Diagram
- Visualization & Validation Strategy
- Challenges & Trade-Offs
- Performance & System Notes
This project implements an end-to-end 3D object measurement pipeline designed to compute accurate dimensions of raw 3D mesh objects.
The system:
- Reads
.objmesh files - Converts mesh geometry into a vertex-based point cloud
- Applies PCA to identify the object’s natural orientation
- Computes a tight Oriented Bounding Box (OBB)
- Outputs length, width, height, and volume
- Visually validates correctness through interactive 3D rendering
The approach reflects real-world workflows used in 3D scanning, CAD inspection, robotics preprocessing, and packaging optimization systems.
- Raw
.objmesh ingestion - Vertex-based point cloud processing
- PCA-based orientation estimation
- Tight OBB dimension and volume computation
- Interactive 3D visualization using Open3D
- Deterministic, CPU-only geometry pipeline
part1/
│
├── data/
│ └── .obj files
│
├── main.py
└── README.md
python3 -m venv venv
source venv/bin/activatepip install numpy open3dpython3 main.pyThe system follows a linear geometry-processing flow, where each stage feeds directly into the next.
flowchart TD
A[OBJ Mesh File] --> B[Open3D Mesh Loader]
B --> C[Vertex Extraction]
C --> D[Point Cloud Centering]
D --> E[PCA Computation]
E --> F[Eigenvalues & Eigenvectors]
F --> G[Rotate Points into PCA Frame]
G --> H[Min-Max Extent Computation]
H --> I[OBB Dimensions & Volume]
I --> J[Open3D Visualization]
J --> K[Interactive Validation]
.objfile is loaded using Open3D- Mesh vertices are extracted for geometric processing
- Centroid of all vertices is computed
- Point cloud is centered to ensure PCA stability
- Covariance matrix is computed from centered points
- Eigen decomposition yields principal axes
- Eigenvectors define object orientation
- Points are rotated into PCA-aligned frame
- Min–max extents are computed
- Dimensions (L × W × H) and volume are calculated
Visualization is treated as proof of correctness, not decoration.
-
Original mesh rendered in gray
-
Oriented Bounding Box rendered in red
-
Interactive camera rotation validates:
- Correct PCA orientation
- Tight bounding box fit
- Absence of axis-aligned bias
This step acts as a visual unit test for the geometry pipeline.
- Raw meshes may be arbitrarily rotated
- PCA ensures deterministic orientation handling
- System computes bounding box volume, not exact mesh volume
- Chosen to match industrial packaging and inspection use-cases
- Open3D relies on OpenGL/X11
- Wayland sessions may require Xorg fallback
- CPU-only computation (no CUDA/GPU dependency)
- PCA operates on a 3×3 covariance matrix
- Suitable for low-resource systems
- Scales linearly with vertex count