Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

3D-Mesh-Measurement-System

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.

Screenshot from 2025-12-23 20-01-10 image

Table of Contents

  1. Overview
  2. Features
  3. Folder Structure
  4. How to Run Locally
  5. System Flow & Design Decisions
  6. Geometry Processing Pipeline
  7. Mermaid Flow Diagram
  8. Visualization & Validation Strategy
  9. Challenges & Trade-Offs
  10. Performance & System Notes

Overview

This project implements an end-to-end 3D object measurement pipeline designed to compute accurate dimensions of raw 3D mesh objects.

The system:

  • Reads .obj mesh 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.


Features

  • Raw .obj mesh 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

Folder Structure

part1/
│
├── data/
│   └── .obj files
│
├── main.py
└── README.md

How to Run Locally

1. Create Virtual Environment

python3 -m venv venv
source venv/bin/activate

2. Install Dependencies

pip install numpy open3d

3. Run the Program

python3 main.py

System Flow & Design Decisions

The system follows a linear geometry-processing flow, where each stage feeds directly into the next.


Mermaid Flow Diagram

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]
Loading

Geometry Processing Pipeline

1. Mesh Ingestion

  • .obj file is loaded using Open3D
  • Mesh vertices are extracted for geometric processing

2. Point Cloud Centering

  • Centroid of all vertices is computed
  • Point cloud is centered to ensure PCA stability

3. PCA Orientation Estimation

  • Covariance matrix is computed from centered points
  • Eigen decomposition yields principal axes
  • Eigenvectors define object orientation

4. Oriented Bounding Box Computation

  • Points are rotated into PCA-aligned frame
  • Min–max extents are computed
  • Dimensions (L × W × H) and volume are calculated

Visualization & Validation Strategy

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.


Challenges & Trade-Offs

1. Orientation Ambiguity

  • Raw meshes may be arbitrarily rotated
  • PCA ensures deterministic orientation handling

2. Bounding Box vs True Volume

  • System computes bounding box volume, not exact mesh volume
  • Chosen to match industrial packaging and inspection use-cases

3. Visualization Backend

  • Open3D relies on OpenGL/X11
  • Wayland sessions may require Xorg fallback

Performance & System Notes

  • 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

About

Python-based 3D geometry pipeline for measuring raw .obj mesh objects using oriented bounding boxes (OBB). It extracts vertex data, applies PCA to find the object’s natural orientation, computes tight bounding box dimensions and volume, and validates results via Open3D-based 3D visualization, similar to real-world 3D scanning, measurement systems.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages