Linux Camera Skill
Camera capture skill for Linux systems. Supports USB webcams (V4L2) and network cameras (RTSP).
Skill directory: INLINECODE0
Dependencies
CODEBLOCK0
Scripts
0. Quick photo (camera_photo.py) — simplest way to take a photo
No flags needed. Just run it.
CODEBLOCK1
Camera aliases: front = /dev/video0, back = /dev/video2. Output goes to /tmp/ by default.
1. List available cameras (camera_list.py)
Detects all V4L2 video devices and prints their names, paths, and supported formats.
CODEBLOCK2
| Parameter | Description | Default |
|---|
| INLINECODE8 | Output as JSON | off |
2. Take a snapshot (camera_snap.py) — primary, recommended
Captures a single frame from a camera and saves it as a JPEG.
CODEBLOCK3
| Parameter | Description | Default |
|---|
| INLINECODE10 | V4L2 device path | INLINECODE11 |
| INLINECODE12 |
RTSP URL (use instead of
--device for IP cameras) | — |
|
--output | Output file path |
/tmp/camera_snap.jpg |
|
--width | Capture width |
1280 |
|
--height | Capture height |
720 |
|
--warmup | Warmup frames to skip (for exposure adjustment) |
5 |
|
--quality | JPEG quality (1–100) |
90 |
3. Record a video clip (camera_clip.py)
Records a video clip from a camera.
CODEBLOCK4
| Parameter | Description | Default |
|---|
| INLINECODE25 | V4L2 device path | INLINECODE26 |
| INLINECODE27 |
RTSP URL (use instead of
--device for IP cameras) | — |
|
--output | Output file path |
/tmp/camera_clip.mp4 |
|
--duration | Recording duration in seconds |
5 |
|
--width | Capture width |
1280 |
|
--height | Capture height |
720 |
|
--fps | Frames per second |
30 |
4. Live streaming (camera_stream.py)
Multi-format live streaming server. Supports MJPEG (low-latency), HLS (adaptive, mobile-friendly), and RTSP re-streaming.
CODEBLOCK5
Open http://<device-ip>:8090 in a browser to view the MJPEG stream.
| Parameter | Description | Default |
|---|
| INLINECODE41 | V4L2 device path | INLINECODE42 |
| INLINECODE43 |
RTSP input URL (use instead of
--device for IP cameras) | — |
|
--port | HTTP server port |
8090 |
|
--width | Capture width |
640 |
|
--height | Capture height |
480 |
|
--fps | Target frames per second |
15 |
|
--enable-hls | Enable HLS output (adaptive bitrate, mobile-friendly) | off |
|
--enable-rtsp | Enable RTSP re-stream output | off |
|
--rtsp-port | RTSP server port (when
--enable-rtsp is used) |
8554 |
Endpoints:
| URL | Description |
|---|
| INLINECODE58 | MJPEG stream (works in <img> tags and browsers) |
| INLINECODE60 |
Single JPEG snapshot |
|
http://<ip>:8090/hls | HLS live page (requires
--enable-hls) |
|
http://<ip>:8090/hls/stream.m3u8 | HLS playlist for VLC or mobile players |
|
rtsp://<ip>:8554/live | RTSP stream (requires
--enable-rtsp) |
|
http://<ip>:8090/status | JSON status (frame age, size, active outputs) |
Examples
CODEBLOCK6
Multiple cameras
If you have multiple cameras (e.g. /dev/video0 and /dev/video2), specify the device:
CODEBLOCK7
Coordinate with robot arm
Combine with the soarm-control skill to look at something and take a photo:
CODEBLOCK8
Linux 摄像头技能
适用于Linux系统的摄像头捕获技能。支持USB摄像头(V4L2)和网络摄像头(RTSP)。
技能目录: ~/.openclaw/workspace/skills/linux-camera/
依赖项
bash
sudo apt-get install -y ffmpeg v4l-utils
脚本
0. 快速拍照(camera_photo.py)— 最简单的拍照方式
无需任何标志参数,直接运行即可。
bash
uv run python scripts/camera_photo.py # 自动检测摄像头,文件名带时间戳
uv run python scripts/camera_photo.py front # 使用 /dev/video0
uv run python scripts/camera_photo.py back # 使用 /dev/video2
uv run python scripts/camera_photo.py front pic.jpg # 自定义文件名 → /tmp/pic.jpg
uv run python scripts/camera_photo.py /dev/video4 # 显式指定设备路径
摄像头别名:front = /dev/video0,back = /dev/video2。输出文件默认保存到 /tmp/ 目录。
1. 列出可用摄像头(camera_list.py)
检测所有V4L2视频设备,并打印其名称、路径和支持的格式。
bash
uv run python scripts/camera_list.py
2. 拍摄快照(camera_snap.py)— 主要推荐方式
从摄像头捕获单帧图像并保存为JPEG格式。
bash
uv run python scripts/camera_snap.py --output /tmp/snapshot.jpg
| 参数 | 描述 | 默认值 |
|---|
| --device | V4L2设备路径 | /dev/video0 |
| --rtsp |
RTSP URL(用于IP摄像头,替代--device) | — |
| --output | 输出文件路径 | /tmp/camera_snap.jpg |
| --width | 捕获宽度 | 1280 |
| --height | 捕获高度 | 720 |
| --warmup | 预热帧数(用于曝光调整) | 5 |
| --quality | JPEG质量(1–100) | 90 |
3. 录制视频片段(camera_clip.py)
从摄像头录制视频片段。
bash
uv run python scripts/camera_clip.py --duration 5 --output /tmp/clip.mp4
| 参数 | 描述 | 默认值 |
|---|
| --device | V4L2设备路径 | /dev/video0 |
| --rtsp |
RTSP URL(用于IP摄像头,替代--device) | — |
| --output | 输出文件路径 | /tmp/camera_clip.mp4 |
| --duration | 录制时长(秒) | 5 |
| --width | 捕获宽度 | 1280 |
| --height | 捕获高度 | 720 |
| --fps | 每秒帧数 | 30 |
4. 实时推流(camera_stream.py)
多格式实时推流服务器。支持MJPEG(低延迟)、HLS(自适应、移动端友好)和RTSP重新推流。
bash
uv run python scripts/camera_stream.py --port 8090
在浏览器中打开 http://<设备IP>:8090 即可查看MJPEG流。
| 参数 | 描述 | 默认值 |
|---|
| --device | V4L2设备路径 | /dev/video0 |
| --rtsp |
RTSP输入URL(用于IP摄像头,替代--device) | — |
| --port | HTTP服务器端口 | 8090 |
| --width | 捕获宽度 | 640 |
| --height | 捕获高度 | 480 |
| --fps | 目标每秒帧数 | 15 |
| --enable-hls | 启用HLS输出(自适应码率、移动端友好) | 关闭 |
| --enable-rtsp | 启用RTSP重新推流输出 | 关闭 |
| --rtsp-port | RTSP服务器端口(使用--enable-rtsp时) | 8554 |
端点地址:
| URL | 描述 |
|---|
| http://<ip>:8090/ | MJPEG流(可在<img>标签和浏览器中使用) |
| http://<ip>:8090/snap |
单张JPEG快照 |
| http://
:8090/hls | HLS直播页面(需要--enable-hls) |
| http://:8090/hls/stream.m3u8 | 供VLC或移动播放器使用的HLS播放列表 |
| rtsp://:8554/live | RTSP流(需要--enable-rtsp) |
| http://:8090/status | JSON状态信息(帧龄、尺寸、活跃输出) |
示例
bash
列出摄像头
uv run python scripts/camera_list.py
从默认摄像头拍摄快照
uv run python scripts/camera_snap.py
从指定摄像头拍摄快照
uv run python scripts/camera_snap.py --device /dev/video2 --output /tmp/photo.jpg
从IP摄像头拍摄快照
uv run python scripts/camera_snap.py --rtsp rtsp://user:pass@192.168.1.100:554/stream1
录制10秒视频
uv run python scripts/camera_clip.py --duration 10
MJPEG推流(低延迟,在浏览器中查看)
uv run python scripts/camera_stream.py --port 8090
MJPEG + HLS推流(自适应码率,适合移动/远程设备)
uv run python scripts/camera_stream.py --port 8090 --enable-hls
完整推流:MJPEG + HLS + RTSP重新推流
uv run python scripts/camera_stream.py --port 8090 --enable-hls --enable-rtsp
以IP摄像头作为输入源进行推流
uv run python scripts/camera_stream.py --rtsp rtsp://user:pass@192.168.1.100:554/stream1 --enable-hls
30fps高分辨率推流
uv run python scripts/camera_stream.py --width 1280 --height 720 --fps 30
多摄像头支持
如果您有多个摄像头(例如 /dev/video0 和 /dev/video2),请指定设备:
bash
列出所有摄像头
uv run python scripts/camera_list.py
从摄像头0拍摄快照
uv run python scripts/camera_snap.py --device /dev/video0 --output /tmp/cam0.jpg
从摄像头2拍摄快照
uv run python scripts/camera_snap.py --device /dev/video2 --output /tmp/cam2.jpg
在端口8090推流摄像头0,在端口8091推流摄像头2
uv run python scripts/camera_stream.py --device /dev/video0 --port 8090
uv run python scripts/camera_stream.py --device /dev/video2 --port 8091
与机械臂协同
结合 soarm-control 技能,可以控制机械臂观察某处并拍照:
bash
移动机械臂观察桌面
uv run python ~/.openclaw/workspace/skills/soarm-control/scripts/soarmsetjoints.py \
--shoulder-pan 1.626 --shoulder-lift -42.110 --elbow-flex 32.088 \
--wrist-flex 78.242 --wrist-roll -95.077
捕获摄像头看到的画面
uv run python scripts/camera_snap.py --output /tmp/desktop.jpg