ubuntu realsense huoqutuxiang
时间: 2023-07-06 18:04:03 浏览: 54
要在 Ubuntu 上获取 RealSense 相机的图像,您需要安装 RealSense SDK。以下是一些步骤:
1. 在终端中更新 apt-get 列表:
```
sudo apt-get update
```
2. 安装 RealSense SDK:
```
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
```
3. 您可以使用以下命令验证 SDK 是否正确安装:
```
realsense-viewer
```
4. 如果您需要使用 Python 脚本访问相机,请安装以下软件包:
```
sudo apt-get install python3-pip
sudo apt-get install python3-opencv
sudo pip3 install pyrealsense2
```
5. 您可以使用以下 Python 代码捕获相机图像:
```python
import pyrealsense2 as rs
# 创建 Pipeline 对象
pipeline = rs.pipeline()
config = rs.config()
# 启用深度和彩色流
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
# 启动摄像头并获取帧
pipeline.start(config)
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_frame()
# 将帧转换为 numpy 数组
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
# 关闭 Pipeline 对象
pipeline.stop()
```
这应该可以帮助您开始使用 RealSense 相机在 Ubuntu 上捕获图像。