|
| 1 | +VisionProStreamer |
| 2 | +================= |
| 3 | + |
| 4 | +The main interface for receiving tracking data and streaming video. |
| 5 | + |
| 6 | +.. automodule:: avp_stream.streamer |
| 7 | + :members: |
| 8 | + :undoc-members: |
| 9 | + :show-inheritance: |
| 10 | + :special-members: __init__ |
| 11 | + |
| 12 | +Classes |
| 13 | +------- |
| 14 | + |
| 15 | +.. autoclass:: avp_stream.streamer.VisionProStreamer |
| 16 | + :members: |
| 17 | + :undoc-members: |
| 18 | + :show-inheritance: |
| 19 | + :special-members: __init__ |
| 20 | + |
| 21 | + .. automethod:: __init__ |
| 22 | + .. automethod:: start_video_streaming |
| 23 | + .. automethod:: register_frame_callback |
| 24 | + .. automethod:: stop |
| 25 | + .. autoproperty:: latest |
| 26 | + |
| 27 | +Main Methods |
| 28 | +^^^^^^^^^^^^ |
| 29 | + |
| 30 | +.. py:method:: __init__(ip: str, port: int = 50051) |
| 31 | +
|
| 32 | + Initialize the Vision Pro streamer. |
| 33 | + |
| 34 | + :param ip: IP address of the Vision Pro device |
| 35 | + :type ip: str |
| 36 | + :param port: gRPC port number (default: 50051) |
| 37 | + :type port: int |
| 38 | + |
| 39 | +.. py:method:: start_video_streaming(device, format, size, fps, stereo=False) |
| 40 | +
|
| 41 | + Start streaming video back to Vision Pro. |
| 42 | + |
| 43 | + :param device: Path to video device (e.g., "/dev/video0") or None for synthetic |
| 44 | + :type device: str or None |
| 45 | + :param format: Video format (e.g., "v4l2", "dshow", "avfoundation") or None |
| 46 | + :type format: str or None |
| 47 | + :param size: Frame size as string (e.g., "640x480") |
| 48 | + :type size: str |
| 49 | + :param fps: Frames per second |
| 50 | + :type fps: int |
| 51 | + :param stereo: Whether to stream stereo video (side-by-side format) |
| 52 | + :type stereo: bool |
| 53 | + |
| 54 | +.. py:method:: register_frame_callback(callback) |
| 55 | +
|
| 56 | + Register a function to process frames before streaming. |
| 57 | + |
| 58 | + :param callback: Function that takes a frame (numpy array) and returns processed frame |
| 59 | + :type callback: callable |
| 60 | + |
| 61 | +.. py:method:: stop() |
| 62 | +
|
| 63 | + Stop the streamer and release resources. |
| 64 | + |
| 65 | +.. py:property:: latest |
| 66 | +
|
| 67 | + Get the latest tracking data. |
| 68 | + |
| 69 | + :return: Dictionary containing tracking data |
| 70 | + :rtype: dict |
| 71 | + |
| 72 | + Dictionary keys: |
| 73 | + |
| 74 | + - ``head``: (1, 4, 4) numpy array - head pose in ground frame |
| 75 | + - ``right_wrist``: (1, 4, 4) numpy array - right wrist pose in ground frame |
| 76 | + - ``left_wrist``: (1, 4, 4) numpy array - left wrist pose in ground frame |
| 77 | + - ``right_fingers``: (25, 4, 4) numpy array - right finger joints in wrist frame |
| 78 | + - ``left_fingers``: (25, 4, 4) numpy array - left finger joints in wrist frame |
| 79 | + - ``right_pinch_distance``: float - distance between right thumb and index finger |
| 80 | + - ``left_pinch_distance``: float - distance between left thumb and index finger |
| 81 | + - ``right_wrist_roll``: float - rotation angle of right wrist around arm axis |
| 82 | + - ``left_wrist_roll``: float - rotation angle of left wrist around arm axis |
| 83 | + |
| 84 | +Example Usage |
| 85 | +^^^^^^^^^^^^^ |
| 86 | + |
| 87 | +Basic usage:: |
| 88 | + |
| 89 | + from avp_stream import VisionProStreamer |
| 90 | + |
| 91 | + avp_ip = "10.31.181.201" |
| 92 | + streamer = VisionProStreamer(ip=avp_ip) |
| 93 | + |
| 94 | + while True: |
| 95 | + data = streamer.latest |
| 96 | + print(data['head'], data['right_wrist']) |
| 97 | + |
| 98 | +With video streaming:: |
| 99 | + |
| 100 | + streamer = VisionProStreamer(ip=avp_ip) |
| 101 | + streamer.start_video_streaming( |
| 102 | + device="/dev/video0", |
| 103 | + format="v4l2", |
| 104 | + size="640x480", |
| 105 | + fps=30 |
| 106 | + ) |
| 107 | + |
| 108 | + while True: |
| 109 | + data = streamer.latest |
| 110 | + # Process tracking data |
| 111 | + |
| 112 | +With frame processing:: |
| 113 | + |
| 114 | + def process_frame(frame): |
| 115 | + # Add overlay or processing |
| 116 | + return frame |
| 117 | + |
| 118 | + streamer = VisionProStreamer(ip=avp_ip) |
| 119 | + streamer.register_frame_callback(process_frame) |
| 120 | + streamer.start_video_streaming( |
| 121 | + device="/dev/video0", |
| 122 | + format="v4l2", |
| 123 | + size="640x480", |
| 124 | + fps=30 |
| 125 | + ) |
0 commit comments