Skip to content

Comments

Hardware/feature/photoneo#362

Open
Yasserelhaddar wants to merge 17 commits intodevfrom
hardware/feature/photoneo
Open

Hardware/feature/photoneo#362
Yasserelhaddar wants to merge 17 commits intodevfrom
hardware/feature/photoneo

Conversation

@Yasserelhaddar
Copy link
Collaborator

Add 3D scanner subsystem with Photoneo backend

Scope and Motivation

The hardware module supports 2D cameras, stereo cameras, PLCs, and sensors — but has no support for structured-light 3D scanners. Industrial inspection workflows require high-resolution 3D scanning (Photoneo PhoXi, MotionCam-3D) for dimensional measurement, surface defect detection, and bin picking.

This PR adds a complete 3D scanner subsystem following the same layered architecture as the existing subsystems: Backend → Core → Service → CLI.

Changes Included

Backend layer

  • Scanner3DBackend — abstract async base class with multi-component capture, point cloud generation, configuration, and thread-affinity support
  • PhotoneoBackend — production backend using Harvesters/GigE Vision with Matrix Vision mvGenTL Producer. Supports Range, Intensity, Confidence, Normals, and Color capture components, plus Coord3D point cloud generation
  • MockPhotoneoBackend — full-fidelity mock for development and CI. Two simulated devices (PhoXi M and L) generating synthetic scan data without any hardware dependency

Core layer

  • AsyncScanner3D / Scanner3D — async and sync high-level interfaces with factory method open("Photoneo:serial") for backend routing
  • Data models: ScanResult, PointCloudData, CoordinateMap, ScannerConfiguration, ScannerCapabilities and configuration enums

Service layer

  • REST API with 21 endpoints covering discovery, lifecycle, capture (scan + point cloud), configuration, and batch operations
  • Connection manager for typed client access
  • MCP tool integration

SDK setup (mindtrace-scanner-photoneo)

  • Cross-platform installer for the Matrix Vision mvGenTL Producer v2.49.0
  • Supports Linux, Windows, and macOS
  • Handles post-install environment setup (GENICAM_GENTL64_PATH)
  • Includes verify, discover, and uninstall commands

CLI

  • mindtrace-hw scanner start/stop/status/logs for service lifecycle

Stereo refactor

  • Extracted StereoCameraBackend base class from BaslerStereoAce to enable future stereo backends

Tests & docs

  • Unit and integration tests covering backends, models, configuration, capture, and imports
  • New scanners_3d/README.md with architecture, usage, configuration reference, and extension guide
  • Updated hardware/README.md with scanner setup commands and backend info

How to Test

1. Install the OS-level SDK (Matrix Vision mvGenTL Producer — requires sudo):

mindtrace-scanner-photoneo install -v

2. Install Python dependencies:

uv sync --extra scanners-all

3. Verify everything is wired up:

mindtrace-scanner-photoneo verify -v

4. Discover scanners on the network (if hardware is available):

mindtrace-scanner-photoneo discover --all

5. Try a capture (works without hardware using the mock backend):

import asyncio
from mindtrace.hardware.scanners_3d import AsyncScanner3D

async def main():
    scanner = await AsyncScanner3D.open("MockPhotoneo")

    result = await scanner.capture(enable_range=True, enable_intensity=True)
    print(f"Range: {result.range_shape}, Intensity: {result.intensity_shape}")

    point_cloud = await scanner.capture_point_cloud()
    print(f"Points: {point_cloud.num_points}")

    await scanner.close()

asyncio.run(main())

Impact

  • No breaking changes — entirely additive, no existing APIs modified
  • New optional dependency groupscanners-all extra in pyproject.toml
  • Stereo refactor — extracted base class; existing stereo functionality and tests unaffected
  • New CLI entry pointmindtrace-scanner-photoneo registered in pyproject.toml
  • Network — Photoneo scanners use GigE Vision, requiring host networking for discovery (same as Basler GigE cameras)

Tests that instantiate PhotoneoBackend were failing when the harvesters
SDK is not installed because HARVESTERS_AVAILABLE was set to False at
module import time. Patch the flag to True and provide a mock CTI path
so tests can run without the SDK, matching the pattern used by the
Basler backend tests with PYPYLON_AVAILABLE.
Expand MockPhotoneoBackend to mirror the full PhotoneoBackend interface:
- Add all 16 individual get/set config pairs (exposure, LED/laser power,
  coding strategy/quality, operation mode, trigger mode, etc.)
- Add bulk get_configuration/set_configuration and get_capabilities
- Add connection guard (_check_open) and proper lifecycle methods
- Add organized section headers for readability

This enables realistic offline testing and development without hardware.
….open()

Allow opening mock scanners via name parsing:
  - AsyncScanner3D.open("MockPhotoneo") — first mock device
  - AsyncScanner3D.open("MockPhotoneo:MOCK002") — specific serial

Add _known_backends set to correctly route bare backend names without
the "Backend:serial" colon separator.
…rm install

The setup script was broken: downloads failed due to HTTP 302 redirects,
env vars weren't set post-install, macOS was missing, and CTI detection
was inconsistent between .cti and .so file variants.

Fixes:
- Use assets-2.balluff.com directly (skip redirect from static.matrix-vision.com)
- Add _download_file() helper with urllib.request.urlopen, retry, and progress
- Add _run_command() helper with logging
- Unify CTI detection in get_cti_path() across .cti/.so variants and env vars
- Set GENICAM_GENTL64_PATH for current session after install
- Generate setup_photoneo_env.sh for persistent env configuration
- Add full macOS support (DMG mount/install/unmount)
- Improve Windows install with admin privilege check/elevation
- Improve Windows uninstall with uninstaller search + wmic fallback
- Handle non-zero installer exit from optional components (e.g. kernel modules)
  gracefully — verify CTI presence instead of failing immediately
Add scanners_3d/README.md covering architecture, usage (async/sync/mock),
backends (Photoneo + MockPhotoneo), all 22 configuration parameters,
service endpoints, SDK setup, point cloud generation, and extension guide.

Update hardware README:
- Add mindtrace-scanner-photoneo install to SDK setup sections
- Fix capture modality data shapes (Range is (H,W) not (H,W,3), etc.)
- Add Supported Backends table with MockPhotoneo for testing
- Link to new scanners_3d README instead of services README
- Add PhoXi 3D Scanner models to tested hardware list
@Yasserelhaddar Yasserelhaddar self-assigned this Feb 11, 2026
@Yasserelhaddar Yasserelhaddar added enhancement New feature or request mindtrace-hardware Issues raised from hardware module in mindtrace package labels Feb 11, 2026
Base automatically changed from hw/network-utils to hw/docker-docs February 13, 2026 12:50
Base automatically changed from hw/docker-docs to dev February 18, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request mindtrace-hardware Issues raised from hardware module in mindtrace package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants