A native iOS app for scanning rooms using iPhone's LiDAR sensor and exporting 3D data for Python analysis.
- π± Uses iPhone 16 Pro's LiDAR sensor and ARKit
- π Automatic room detection with RoomPlan framework
- πͺ Detects walls, doors, windows, and furniture
- π Multiple export formats: USD, USDZ, and JSON
- π Python-friendly JSON export for custom analysis
- πΎ Save and manage multiple room scans
- iPhone 16 Pro (or any iPhone with LiDAR: 12 Pro, 13 Pro, 14 Pro, 15 Pro, 16 Pro)
- iOS 17.0 or later
- Xcode 15.0 or later (for building)
- Python 3.8+
- NumPy (for data processing)
- Matplotlib (optional, for visualization)
-
Open Xcode and create a new iOS App project:
- Product Name:
RoomScanner - Interface: SwiftUI
- Language: Swift
- Minimum Deployment: iOS 17.0
- Product Name:
-
Add the source files to your project:
RoomScannerApp.swift(replace the default App file)ContentView.swift(replace the default)ScanningView.swiftScanManager.swiftModels.swift
-
Update Info.plist:
- Replace with the provided
Info.plistfile - Key requirement: Camera usage description for LiDAR access
- Replace with the provided
-
Configure signing:
- Select your development team in "Signing & Capabilities"
- Change the bundle identifier to something unique
-
Add required frameworks: In your target's "Frameworks, Libraries, and Embedded Content", ensure:
- RoomPlan.framework
- ARKit.framework
- RealityKit.framework
- SwiftUI.framework
-
Build and run on your iPhone 16 Pro
# Install required packages
pip install numpy matplotlib
# Optional: Create a virtual environment first
python -m venv room_scanner_env
source room_scanner_env/bin/activate # On Windows: room_scanner_env\Scripts\activate
pip install numpy matplotlib- Launch the app on your iPhone
- Tap the + button to start a new scan
- Grant camera permissions when prompted
- Tap "Start Scan" and slowly move around the room:
- Point the camera at walls, floors, ceiling
- Move slowly and steadily
- Ensure good lighting
- Cover all areas of the room
- Tap "Done" when you've covered the entire room
- Name your scan and save
- Tap on a saved scan in the list
- Choose an export format:
- USD: Best for viewing in AR/3D apps (QuickLook)
- USDZ: Compressed version, good for sharing
- JSON: For Python analysis (recommended for your use case)
- Share or save the file via the iOS share sheet
- Transfer to your computer:
- AirDrop
- iCloud Drive
- USB file transfer
- Email/messaging
from room_scan_loader import RoomScan, visualize_floor_plan
# Load a scan
scan = RoomScan('my_living_room.json')
# Print summary
print(scan.summary())
# Get room dimensions
dims = scan.get_room_dimensions()
print(f"Room: {dims['width']:.2f}m Γ {dims['length']:.2f}m Γ {dims['height']:.2f}m")
# Get wall positions
walls = scan.get_wall_positions()
print(f"Found {len(walls)} walls")
# Get detected objects
objects = scan.get_object_categories()
print(f"Objects: {objects}")
# Visualize floor plan
visualize_floor_plan(scan, show_objects=True)The exported JSON contains:
{
"dimensions": {
"width": 4.5,
"length": 6.2,
"height": 2.8
},
"walls": [
{
"id": "uuid",
"dimensions": {"width": 4.5, "height": 2.8, "thickness": 0.1},
"transform": {
"position": {"x": 0, "y": 0, "z": 0},
"matrix": [[...], [...], [...], [...]]
}
}
],
"doors": [...],
"windows": [...],
"objects": [
{
"id": "uuid",
"category": "table",
"dimensions": {"width": 1.5, "height": 0.7, "depth": 0.8},
"transform": {"position": {...}},
"confidence": "high"
}
]
}- X: Left/Right (meters)
- Y: Up/Down (height, meters)
- Z: Forward/Backward (depth, meters)
- Origin typically at scan start position
All distances are in meters.
You can extend the RoomScan class for your specific needs:
class MyRoomAnalyzer(RoomScan):
def calculate_floor_area(self):
"""Calculate approximate floor area"""
dims = self.get_room_dimensions()
return dims['width'] * dims['length']
def get_furniture_density(self):
"""Calculate furniture items per square meter"""
area = self.calculate_floor_area()
return len(self.objects) / area if area > 0 else 0
def export_to_custom_format(self, output_path):
"""Export to your custom format"""
# Your custom processing here
pass"RoomPlan not available"
- Ensure you're running on a LiDAR-equipped iPhone
- Check iOS version (requires iOS 16+)
Scan quality is poor
- Ensure good lighting
- Move slower
- Cover all areas thoroughly
- Avoid reflective surfaces
App won't build
- Check signing & capabilities
- Verify all frameworks are linked
- Update to latest Xcode
"File not found"
- Check file path is correct
- Ensure file was successfully transferred from iPhone
Import errors
- Install required packages:
pip install numpy matplotlib
from pathlib import Path
from room_scan_loader import RoomScan
scan_dir = Path('scans/')
scans = {}
for json_file in scan_dir.glob('*.json'):
scan = RoomScan(json_file)
scans[json_file.stem] = scan
print(f"{json_file.stem}: {scan.get_room_dimensions()}")# You can combine scans by transforming coordinates
# Example: align rooms to create full house map
def combine_rooms(scans, transforms):
"""
Combine multiple room scans into one coordinate system
scans: list of RoomScan objects
transforms: list of 4x4 transformation matrices
"""
# Your implementation here
pass-
Scanning technique:
- Start from one corner
- Move in a systematic pattern
- Scan ceiling and floor too
- Re-scan areas if quality seems low
-
Room preparation:
- Good, even lighting
- Remove clutter if possible
- Open doors/close doors as desired
-
Data processing:
- Use wall positions to define room boundaries
- Object positions are approximate
- Transform matrices contain full orientation data
- Confidence scores indicate detection quality
Possible additions to the app:
- Multi-room stitching within the app
- Real-time measurement display
- Point cloud export
- Custom object labeling
- Photo textures for walls
RoomScanner/
βββ RoomScannerApp.swift # App entry point
βββ ContentView.swift # Main UI - scan list
βββ ScanningView.swift # RoomPlan scanning interface
βββ ScanManager.swift # Data management & export
βββ Models.swift # Data structures
βββ Info.plist # App configuration
βββ room_scan_loader.py # Python data loader
This project is provided as-is for your personal use.
Built using:
- Apple RoomPlan framework
- ARKit
- SwiftUI
Happy Scanning! π±π
For questions or issues, please refer to Apple's RoomPlan documentation: https://developer.apple.com/documentation/roomplan