--- name: kinect-visualization description: Use Xbox Kinect (or compatible depth cameras) for visualization, interactive installations, and creative coding projects. Covers detection, driver setup, data extraction, and integration with platforms like Touchdesigner, Unity, and Python. version: 1.0.0 author: Hermes Agent license: MIT platforms: [linux, macos, windows] metadata: hermes: tags: [kinect, visualization, depth-camera, touchdesigner, creative-coding] related_skills: [systematic-debugging, plan] --- # Xbox Kinect Visualization Skill ## Overview This skill covers setting up, detecting, and extracting data from an Xbox Kinect (or compatible depth camera) for use in visualization projects, interactive installations, and creative coding. The Kinect provides RGB video, depth data, audio, and skeleton tracking. ## Device Detection ### macOS The Xbox Kinect connects via USB and is identified as: ``` Product: Xbox NUI Sensor Vendor: Microsoft USB Vendor ID: 0x045E (1118) USB Product ID: 0x02C4 (708) Device appears as: Xbox NUI Sensor@02210000 in system profiler ``` **Verify detection:** ```bash system_profiler SPUSBDataType ``` Or via Python: ```python import usb.core dev = usb.core.find(idVendor=0x045E, idProduct=0x02C4) if dev: print('Kinect found!') print('Address:', dev.address) ``` ### Windows Similar USB IDs. Install [libfreenect2](https://github.com/libfreenect2/libfreenect2) or [OpenNI2](https://openni.org/) drivers. ### Linux `libfreenect2`, `OpenNI2`, or direct `libusb` access. ## Driver Options ### 1. OpenNI2 + SensorKinect (Touchdesigner compatible) **macOS:** Install OpenNI2 framework and SensorKinect driver for the Xbox Kinect. **Touchdesigner:** The built-in Kinect CHOP will detect the device once OpenNI2/SensorKinect is installed. ### 2. libfreenect / libfreenect2 (OpenKinect) **Cross-platform:** `brew install libfreenect2` (macOS) or system package managers (Linux/Windows). **Python:** `pip install pykinect2` or `pip install openni2`. ### 3. Touchdesigner Built-in Kinect CHOP In Touchdesigner: `Touch → External Commands → Kinect CHOP`. Select the device when prompted. Requires OpenNI2/SensorKinect drivers on macOS. ## Data Extraction ### Python (usb.core + libusb) ```python import usb.core import usb.util dev = usb.core.find(idVendor=0x045E, idProduct=0x02C4) if dev is None: print('Kinect not found') exit(1) # Detach kernel driver if active if dev.is_kernel_driver_active(0): dev.detach_kernel_driver(0) # Set configuration dev.set_configuration() # Claim interface 0 usb.util.claim_interface(dev, 0) # Read from endpoint (example - find the right endpoint) cfg = dev.get_configuration() for intf in cfg.interfaces(): for alt in intf.altsettings: for ep in alt.endpoints: direction = 'IN' if usb.util.endpoint_direction(ep.bEndpointAddress) == usb.util.ENDPOINT_IN else 'OUT' print(f'EP: {hex(ep.bEndpointAddress)} dir={direction} maxpkt={ep.wMaxPacketSize}') ``` ### Touchdesigner CHOP Parameters - **Device:** Select the Kinect device - **Frame Rate:** 30fps (video), 30fps (depth) - **Output Channels:** Red, Green, Blue, Depth - **Skeleton Tracking:** If using OpenNI2 ## Creative Coding Integration ### Touchdesigner 1. Add Kinect CHOP to your network 2. Connect to TOP/CHOP/SOP components for visualization 3. Use depth data for particle systems, 3D mappings, or interactive surfaces 4. Use video feed for texturing or background removal ### Unity Use the [Kinect Unity Plugin](https://github.com/Kinect/Unity-Kinect) or [OpenNI2 Unity Integration](https://github.com/occipital/openni-unity). ### Python / Processing / OpenFrameworks - `pykinect2` or `openni2` for Python - `ofxKinect` for openFrameworks - KinectToe plugin for Touchdesigner ## Troubleshooting ### Common Issues 1. **Device not found** — Verify USB connection, IDs (0x045E/0x02C4), and that the device is powered. 2. **Kernel driver active** — Detach kernel driver: `dev.detach_kernel_driver(0)` before claiming interface. 3. **Touchdesigner can't see device** — Install OpenNI2 + SensorKinect drivers on macOS. Without these, the Kinect CHOP won't list the device. 4. **Depth data looks wrong** — Ensure correct camera mode (near mode vs. wide mode). Some Kinect models have different depth ranges. 5. **USB bandwidth issues** — Try connecting the Kinect directly to the computer (not through a hub), especially for Kinect v2. ### Error Patterns | Error | Cause | Fix | |-------|-------|-----| | `ValueError: Device not found` | Wrong vendor/product IDs | Verify `idVendor=0x045E, idProduct=0x02C4` | | `USBError: Could not detach kernel driver` | Kernel driver holding interface | Use `dev.detach_kernel_driver(0)` or run with appropriate permissions | | `Kinect CHOP shows no device` | Missing OpenNI2/SensorKinect drivers | Install OpenNI2 framework and SensorKinect driver | | `Depth data is all zeros` | Wrong camera mode or setup | Check Kinect model and mode settings | ## Support Files This skill is packaged with support files in the following directories: - `references/kinect-ids.md` — Condensed device IDs, USB descriptors, and interface layouts - `references/troubleshooting-kinect.md` — Error transcripts, reproduction recipes, provider quirks - `references/freenecttd-plugin.md` — FreenectTD plugin installation guide for TouchDesigner macOS (new) - `scripts/probe-kinect.py` — Deterministic probe script that enumerates Kinect endpoints and validates communication To add a new support file, use `skill_manage` with `file_path` starting `references/` or `scripts/`. The skill's SKILL.md will automatically gain a pointer to the new file. ## Related Skills - `systematic-debugging` — For debugging Kinect connection or data issues - `plan` — For planning Kinect integration projects ## Version History | Version | Date | Changes | |---------|------|---------| | 1.0.0 | — | Initial release — detection, drivers, data extraction, and integration patterns | ## References - Xbox Kinect Technical Specifications - OpenNI2 Framework Documentation - libfreenect2 Project - Touchdesigner Kinect CHOP Documentation - Microsoft Kinect SDK (legacy)