![]() |
MIPI - Physical Interface for MIDI Files
|
A ROS 2 node that detects piano keys using YOLO segmentation and correlates them with AprilTag markers via an Intel RealSense camera.
System Requirements
ROS 2 Packages
RealSense camera driver:
AprilTag detection:
Python Packages
Important Note: If CUDA is unavailable, the node will fall back to CPU automatically, but inference will be significantly slower.
Ensure the trained weights file is located at the correct path relative to your workspace root before running the node.
Note: To shut down the OpenCV window, press
q.
The AprilTagPianoDetector node exposes no public class members and is instantiated by calling main(). See below for all ROS 2 interfaces exposed at runtime.
| Interface Name | Type | Description |
|---|---|---|
subscription | sensor_msgs/Image | Raw colour stream from the RealSense camera. Triggers the full detection pipeline on every frame. |
| Interface Name | Type | Description |
|---|---|---|
publisher_tag | geometry_msgs/Point | Normalised (x, y) offset of the detected AprilTag from the frame centre. Range [-1.0, 1.0]. Positive x = right, positive y = up. z is unused. |
publisher_keys | geometry_msgs/PoseArray | Left-to-right ordered array of detected piano key centroids. Each pose.position.x/y is the adjusted centroid in pixel coordinates. |
The following constants at the top of the code can be adjusted without modifying any other part of the code.
| Constant | Default | Description |
|---|---|---|
YOLO_IMG_SIZE | 640 | Input resolution fed to YOLO (pixels, square crop) |
YOLO_SKIP | 1 | Run YOLO every N frames. Increase to reduce CPU/GPU load |
YOLO_HALF | True | FP16 half-precision inference on CUDA (faster, slightly less accurate) |
DISPLAY_SCALE | 1.0 | Scale factor applied to the OpenCV preview window |
WHITE_KEY_OFFSET | (0, 30) | Pixel offset (dx, dy) added to white key centroids before publishing |
BLACK_KEY_OFFSET | (0, 10) | Pixel offset (dx, dy) added to black key centroids before publishing |