Skip to content

stephencorderinf0inf/-point-cloud-detection

Repository files navigation

snapshot_00-001 snapshot001 # Point Cloud Detection Scanner 🔴🎯

Advanced 3D Scanner optimized for full spectrum dot distance detection (635nm Red Laser)

Laser triangulation-based 3D scanner with AI depth estimation, real-time visualization, and mesh generation.


🚀 Features

Core Scanning Modes

  • 🔴 Mode 1: Red Laser (635nm) - Precise laser dot triangulation for high-accuracy 3D scanning
  • 🌈 Mode 2: Curve Trace - Detect and trace continuous curves/contours
  • 📐 Mode 3: Corner Detection - Find corners and feature points
  • 🤖 Mode 4: AI Depth - Monocular depth estimation using V2 or MiDaS neural network

3D Visualization

  • MeshLab suggested for point cloud visualization

Mesh Generation

  • Poisson Surface Reconstruction - Watertight, smooth meshes
  • Ball Pivoting Algorithm (BPA) - Faithful to original data
  • Screened Algorithm
  • Auto-generates mesh on save (.obj + .ply formats)

Advanced Features

  • Lazy Loading - 60-80% faster startup (loads AI modules only when needed)
  • Spectrum Analyzer - Multi-wavelength laser detection (380-1000nm)
  • Camera Calibration - Automatic distortion correction
  • Auto-capture Mode - 3-snapshot rotation workflow
  • ROI (Region of Interest) - Crop scan area with scissors tool
  • GPU Acceleration - CUDA support for undistortion & depth estimation
  • Quality Monitoring - Real-time sharpness & brightness analysis

📦 Installation

Requirements

  • Python 3.8+
  • Webcam (1280x720 recommended)

⚠️ Performance Note (CPU Users)

Infinity Gem is optimized for CPU-based reconstruction, but extremely large point clouds can take time to process. On a 32 GB RAM / 22‑core CPU system, generating a 2–3 million point cloud takes approximately 4 minutes. Performance will vary based on hardware and input complexity.

⚠️ Performance Warning

Infinity Gem supports both CPU and GPU reconstruction. Large point sets (2–3 million points or more) are GPU‑accelerated and will run significantly faster on a capable GPU. CPU processing is still supported but may take several minutes depending on your hardware.


🚀 Easy Setup (Windows) - RECOMMENDED

Run the automated installer:

install.bat

This will:

  • ✅ Check Python installation
  • ✅ Install dependencies with options (Basic or Full)
  • ✅ Create default calibration
  • ✅ Guide you through first launch

Setup time: 5-10 minutes


Manual Installation

Quick Install (Basic laser scanning):

pip install opencv-python numpy

Full Install (AI depth + 3D viewer):

pip install -r requirements.txt

GPU Acceleration (Optional - 10x faster AI depth):

# Install CUDA 11.8 or 12.x from NVIDIA first
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
pip install opencv-python numpy timm open3d psutil

🎮 Usage

Launch Scanner

cd scanning
python laser_3d_scanner_advanced.py

Keyboard Controls

Key Action Description
1/2/3/4 Mode Switch Full Spectrum / Curve / Corners / AI Depth
SPACE Capture Add points to 3D cloud
S Save Export .ply + auto-generate mesh
C Clear Delete all captured points
M Mesh Method Toggle Poisson / Ball Pivoting
V Cartoon Mode Toggle camera cartoon-style settings
P Spectrum Cycle Switch laser wavelength (635nm / 532nm / 450nm / IR / Full)
+/- Curve Sample Adjust curve point sampling rate
[/] Corner Count Adjust max corner detection limit
,/. Edge Threshold Adjust Canny edge sensitivity
I AI Panel Toggle AI quality panel visibility
B Controls Panel Toggle keyboard controls display
Q/ESC Quit Exit scanner

Depth Mode (Mode 4 - AI):

Key Action
Z Toggle depth visualization overlay
X Toggle sparse/dense point cloud
W/E Adjust min depth range
R/F Adjust max depth range

📁 Project Structure

point_cloud_detection/
├── scanning/                    # Main scanner module
│   ├── laser_3d_scanner_advanced.py  # Main scanner (2600+ lines)
│   ├── depth_estimator.py       # AI depth estimation (MiDaS)
│   ├── spectrum_config.py       # Multi-wavelength laser detection
│   ├── panel_display_module.py  # UI panels and overlays
│   ├── gpu_optimizer.py         # CUDA acceleration
│   ├── calibration_helper.py    # Auto-setup for new users
│   ├── camera_identifier.py     # Camera fingerprinting
│   ├── SCANNER_MATRIX.py        # Fast lookup reference
│   └── data/                    # Scan output folder
│       └── point_clouds/        # .ply, .obj, .npz files
│
├── calibration/                 # Camera calibration tools
│   ├── camera_distance_detector_calibrated.py
│   └── checkerboard.py          # Calibration pattern generator
│
├── ai_analysis/                 # AI quality analysis
│   ├── camera_info.py           # FPS, exposure, resolution
│   ├── image_quality.py         # Sharpness, brightness detection
│   └── optimized_analyzer.py    # GPU-accelerated analysis
│
├── utils/                       # Utilities
│   ├── project_manager.py       # Scan project organization
│   └── system_requirements.py   # Dependency checker
│
├── requirements.txt             # Python dependencies
├── .gitignore                   # Git exclusions
└── README.md                    # This file

🎯 Workflow Example

1. First-Time Setup

# Calibrate camera (auto-generates checkerboard)
python calibration/checkerboard.py
# Follow on-screen instructions for 15-20 images

# Alternative: Use default calibration (less accurate)
# Scanner auto-detects and offers to generate checkerboard

2. Basic Scanning

  1. Launch scanner: `python laser_3d_scanner_advanced.py
  2. Press SPACE to capture points
  3. Rotate object, capture more points
  4. Press S to save (auto-generates mesh)

3. AI Depth Scanning (No laser required)

  1. Press 4 for AI Depth mode
  2. Position camera to view object
  3. Press SPACE to capture dense depth map
  4. Press S to save

🔧 Configuration

Camera Settings

Edit laser_3d_scanner_advanced.py:

# Line ~1711
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

Laser Color (for non-635nm lasers)

Edit spectrum_config.py or press P to cycle presets:

  • Full Spectrum - Default
  • 532nm Green
  • 450nm Blue
  • 780nm Near-IR
  • Full Spectrum (380-1000nm)

Save Location

On first run, scanner prompts for save folder:

  • Option 1: scanning/ folder
  • Option 2: Custom path (enter manually)

📊 Output Files

Point Clouds

  • scan_3d_YYYYMMDD_HHMMSS.ply - Colored point cloud (ASCII)
  • scan_3d_bosch_glm42.npz - Compressed NumPy format

Meshes (Auto-generated)

  • scan_*_mesh.obj - Poisson or BPA mesh
  • scan_*_mesh.ply - Mesh in PLY format

Metadata

  • Rotation angles
  • Session timestamps
  • Calibration fingerprint

🐛 Troubleshooting

"Depth estimation unavailable"

# Install PyTorch + dependencies
pip install torch torchvision timm

"Camera not found"

# Change camera index in laser_3d_scanner_advanced.py
WEBCAM_INDEX = 1  # Try 0, 1, 2...

"Calibration file not found"

Scanner auto-generates checkerboard and guides setup. Or:

python calibration/checkerboard.py

Slow AI depth mode

Enable GPU acceleration (see Installation → GPU Acceleration)

3D Viewer shrinks video window

Fixed in v2.0 - viewer now positions in top-right corner


📝 Technical Details

Laser Triangulation

  • Method: Dot centroid detection with sub-pixel accuracy
  • Range: Configurable via calibration (typically 20-200cm)
  • Accuracy: ±2mm at 1m distance (with calibration)

AI Depth Estimation

  • Model: MiDaS DPT-Large (Intel ISL)
  • Input: Single RGB image
  • Output: Dense depth map (downsampled 2x-4x)
  • Speed: ~2 FPS (CPU), ~15 FPS (GPU RTX 3060)

Mesh Algorithms

  • Poisson: 8-10 octree depth, watertight surfaces
  • BPA: 5mm ball radius, preserves fine details
  • Screened

🔗 Dependencies

Package Purpose Required
opencv-python Camera capture, image processing ✅ Yes
numpy Array operations, point clouds ✅ Yes
torch AI depth neural network ⚠️ Optional
torchvision Image transforms for AI ⚠️ Optional
V2 AI Assist Standalone depth AI module (zip) ⚠️ Optional
timm MiDaS DPT model support ⚠️ Optional
psutil System monitoring ⚠️ Optional

📜 License

See LICENSE file.


Trademark Notice

Infinity Gem™ and Infinity Gems™ are unregistered trademarks of the project’s author.
All branding, logos, names, and visual identifiers associated with Infinity Gem(s) are the exclusive intellectual property of the author and are not covered by the Apache 2.0 license.

The open-source code may be used under the terms of the Apache License, Version 2.0, but the Infinity Gem(s) name, branding, and associated marks may not be used to imply endorsement, affiliation, or official status without prior written permission.

Brand Usage Policy

The Infinity Gem™ / Infinity Gems™ name, branding, and visual identity are protected intellectual property of the project’s author. These elements are NOT licensed under the Apache 2.0 license.

Permitted Use

  • You may state that your project “uses the Infinity Gem open-source software” as long as it is factual.
  • You may link to the official repository.
  • You may fork the code under the terms of the Apache 2.0 license.

Restricted Use

You may NOT:

  • Use the Infinity Gem(s) name or branding in a way that suggests your fork or product is the official version.
  • Use the name or branding in commercial products without written permission.
  • Use the name or branding in a way that causes confusion about origin, affiliation, or endorsement.
  • Create logos, marks, or product names that are confusingly similar.

Commercial Use

Commercial use of the Infinity Gem(s) brand, name, or identity requires a separate written agreement with the author.
The Apache 2.0 license does not grant rights to use the brand in commercial contexts.

Enforcement

Unauthorized use of the Infinity Gem(s) brand may result in legal action under applicable trademark and unfair competition laws.

🤝 Contributing

This is a private repository for development. Contributions welcome after review.


📧 Support

For issues or questions, check:

  1. Troubleshooting section above
  2. Code comments in laser_3d_scanner_advanced.py
  3. SCANNER_MATRIX.py for quick reference

Last Updated: December 13, 2025
Version: 2.0 (Lazy Loading )

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors