mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-10 21:59:54 -05:00
1. Introduction
This application is developed based on the MaixCam series hardware platform. It integrates the TOF100 depth sensor with a camera module to achieve functions such as depth data acquisition, visual image fusion, and data visualization. The application can collect depth matrix data from the TOF100 in real-time and supports fusing this depth data with camera images for intuitive display on a screen. It is suitable for scenario verification and functional demonstration of short-range (4cm-75cm) depth perception and visual fusion.
2. Main Features
- Depth Data Acquisition: Collects depth matrix data at resolutions of 25×25, 50×50, or 100×100 via the TOF100 sensor, supporting an effective detection range of 4cm to 75cm.
- Visual Fusion Processing: Fuses images captured by the camera with TOF depth data to generate visual images containing depth information.
- Multi-Resolution Adaptation: Supports switching between different depth data resolutions (25×25/50×50/100×100) and automatically adapts the display output.
- Real-Time Visualization: Scales depth data or fused images to fit the display resolution for real-time viewing. Supports crosshair annotations for depth extrema (minimum, maximum, and center points).
- Touch Interaction: Enables basic interaction via the touchscreen, such as exiting the application if the device is not detected.
3. User Guide
3.1 Hardware Preparation
- Confirm the hardware platform is MaixCAM or MaixCAM2 (SPI ports are automatically adapted for different platforms).
- Connect the TOF100 sensor to the corresponding SPI interface (SPI4 for MaixCAM, SPI2 for MaixCAM2).
- Connect the camera module (defaults to 50×50 resolution, supports dynamic adjustment).
- Connect the display and touchscreen, ensuring hardware drivers are functioning correctly.
3.2 Application Startup
- Deploy the compiled application to the Maix hardware platform.
- Execute the application; no additional command-line parameters are required. The program will automatically initialize the hardware and start.
- Upon startup, the program automatically detects the TOF100 sensor. If not detected, the screen displays a "Devices Not Found!" message, and you can exit by touching the screen.
3.3 Operation
- Default Mode: Automatically enters depth data display mode upon startup, showing a real-time visualization of depth data collected by the TOF100.
- Fusion Mode Switch: When fusion mode is enabled, the program automatically captures camera images and displays them fused with depth data.
- Resolution Switch: The program supports dynamic switching of depth data resolution (25×25/50×50/100×100). After switching, it automatically re-initializes the depth mapping table and adapts the display.
- Exit Application: The application can be exited via a system signal (e.g., Ctrl+C) or touchscreen operation (when the device is not detected).
3.4 Exception Handling
- If hardware initialization fails (display/camera/touchscreen/TOF100), the program outputs an error log and exits.
- If depth matrix data is empty during operation, the program skips the current frame and continues running without interrupting the overall process.
- When adjusting the camera resolution, the program automatically resets and re-initializes the camera, skipping some frames briefly during this period.
4. Notes
- Hardware Compatibility: SPI ports differ between Maix platforms (MaixCAM/MaixCAM2). The program automatically adapts, requiring no manual modification, but ensure hardware wiring corresponds correctly.
- Detection Range: The effective detection range of the TOF100 is 4cm-75cm. Data outside this range may be invalid, and the program applies threshold filtering.
- Resolution Limitation: Visual fusion mode only supports depth data at 50×50 resolution; switching to other resolutions will automatically revert to 50×50.
- Resource Release: The program automatically releases hardware resources (display, camera, TOF100) upon exit to prevent resource leaks caused by forced power-off.
- Performance Tips: If the frame rate is too low during operation, reduce the depth data resolution or disable visual fusion mode.
- Data Visualization Logic: Depth data is converted to an RGB image using a Color Map (cmap), where different colors correspond to different depth values. In fusion mode, brightness information from the camera image is overlaid.
- Display Adaptation: The program automatically adjusts the image position based on the display aspect ratio to ensure the image is centered.
- Debugging Reserves: The program retains some debugging code (e.g., frame rate printing, coordinate printing, test image drawing), which can be enabled via compilation macros to facilitate functional debugging and customized development.
- Expandability: Parameters such as depth thresholds (OPNS_MIN_DIS_MM/OPNS_MAX_DIS_MM) and fusion weights can be modified to adapt to different application scenarios.