A computer vision project that estimates the physical dimensions (height, length, width) of a box using depth sensor data and RANSAC plane fitting.
This project processes Kinect depth camera data to:
- Extract and visualize amplitude and distance images
- Apply morphological filtering to reduce noise
- Use RANSAC to detect floor and box top planes
- Calculate box dimensions from 3D point cloud data
- Visualize results with annotated overlays
- Data Processing: Load and explore Kinect .mat files containing amplitude, distance, and point cloud data
- Noise Reduction: Apply median and mean filters to improve signal quality
- Plane Detection: Robust RANSAC implementation for floor and box-top plane extraction
- Dimension Measurement: Calculate height (plane-to-plane distance), length, and width (corner-to-corner distances)
- Visualization: Multiple visualization modes including:
- Amplitude and distance images
- 3D point cloud plots
- Segmented masks with color overlays
- Corner detection and annotation
numpy
scipy
matplotlib
pathlib- Open
Box_Size_Estimation.ipynbin Jupyter or VS Code - Run cells sequentially from top to bottom
- Select which example to process by uncommenting the appropriate lines in the data loading cell
- Load Kinect sensor data from .mat files
- Visualize amplitude and distance images
- Analyze depth value distributions
- Apply median filter (3×3) to distance data to reduce speckle noise
- Apply mean/median filters to amplitude data
- Remove invalid pixels (NaN, zero, negative values)
- Filter by amplitude threshold to remove weak signals
- Remove extreme distance values using percentile-based thresholding
- Extract valid 3D points from point cloud
- Run RANSAC to fit a plane to the floor
- Parameters:
max_iter=5000,distance_thresh=0.05 - Apply morphological opening/closing to clean floor mask
- Remove floor inliers from candidate points
- Run second RANSAC to detect box top plane
- Parameters:
max_iter=2000,distance_thresh=0.007 - Extract largest connected component as box top
- Height: Calculate perpendicular distance between floor and box-top planes
- Length & Width:
- Detect 4 corners from box mask using extreme pixel coordinates
- Map corners to 3D coordinates
- Compute pairwise distances
- Extract edge lengths (ignoring diagonals)
- Generate overlay with color-coded regions:
- Background: Light blue
- Floor: Navy (dark blue)
- Box top: Crimson (red)
- Corners: Orange markers
.
├── Box_Size_Estimation.ipynb # Main notebook
├── data/ # Kinect sensor data files
│ ├── example1kinect.mat
│ ├── example2kinect.mat
│ ├── example3kinect.mat
│ └── example4kinect.mat
└── README.md # This file