56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
import pyrealsense2 as rs
|
|
|
|
# 创建管道
|
|
pipeline = rs.pipeline()
|
|
|
|
# 配置管道
|
|
config = rs.config()
|
|
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
|
|
config.enable_stream(rs.stream.color, 1280, 720, rs.format.bgr8, 30)
|
|
|
|
# 启动管道
|
|
profile = pipeline.start(config)
|
|
|
|
# 等待帧
|
|
frames = pipeline.wait_for_frames()
|
|
|
|
# 获取深度帧和彩色帧
|
|
depth_frame = frames.get_depth_frame()
|
|
color_frame = frames.get_color_frame()
|
|
|
|
# 获取深度帧和彩色帧的stream_profile
|
|
depth_profile = depth_frame.get_profile()
|
|
color_profile = color_frame.get_profile()
|
|
|
|
# 获取外参
|
|
extrinsics = depth_profile.get_extrinsics_to(color_profile)
|
|
|
|
# 打印外参
|
|
print("Extrinsics: ", extrinsics) # 这里会打印出外参的旋转和平移信息
|
|
|
|
# 获取并打印内参
|
|
depth_intrinsics = depth_profile.as_video_stream_profile().get_intrinsics()
|
|
color_intrinsics = color_profile.as_video_stream_profile().get_intrinsics()
|
|
|
|
print("Depth Intrinsics: ")
|
|
print("width: ", depth_intrinsics.width)
|
|
print("height: ", depth_intrinsics.height)
|
|
print("fx: ", depth_intrinsics.fx)
|
|
print("fy: ", depth_intrinsics.fy)
|
|
print("ppx: ", depth_intrinsics.ppx)
|
|
print("ppy: ", depth_intrinsics.ppy)
|
|
print("model: ", depth_intrinsics.model) # 畸变模型
|
|
print("coeffs: ", depth_intrinsics.coeffs) # 畸变系数
|
|
|
|
print("Color Intrinsics: ")
|
|
print("width: ", color_intrinsics.width)
|
|
print("height: ", color_intrinsics.height)
|
|
print("fx: ", color_intrinsics.fx)
|
|
print("fy: ", color_intrinsics.fy)
|
|
print("ppx: ", color_intrinsics.ppx)
|
|
print("ppy: ", color_intrinsics.ppy)
|
|
print("model: ", color_intrinsics.model) # 畸变模型
|
|
print("coeffs: ", color_intrinsics.coeffs) # 畸变系数
|
|
|
|
# 停止管道
|
|
pipeline.stop() |