lidar-camera-fusion
激光-相机融合技能 - 深度学习融合、几何投影融合、3D检测、ROS2标定与同步
от MIUAV★ 30 звёзд на GitHub
Установить lidar-camera-fusion в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
激光-相机融合技能
用于实现激光雷达与相机的深度融合,涵盖几何投影融合、深度学习融合(CNN/Transformer)、3D目标检测和 ROS2 集成
何时使用
当需要以下帮助时使用此技能:
- 激光雷达与相机外参标定
- 几何投影融合(LiDAR → 图像)
- 深度学习融合检测(PointPillars + 图像)
- 3D 目标检测(BEV + 相机融合)
- 多模态感知系统 ROS2 部署
快速参考
融合策略对比
融合层级:
├── 原始数据层 (Early Fusion) → 点云 + 图像原始数据 concat
├── 特征层 (Deep Fusion) → 点云特征 + 图像特征在网络内融合
├── 决策层 (Late Fusion) → 各自检测结果加权融合
└── 混合融合 (Hybrid) → 多层融合组合
核心依赖
# 基础
sudo apt install -y ros-humble-depthimage-to-laserscan
sudo apt install -y ros-humble-pointcloud-to-laserscan
# 标定
sudo apt install -y ros-humble-calibration-camera-lidar
# 深度学习(可选)
pip install open3d torch torchvision
核心话题
| 话题 | 类型 | 说明 |
|---|---|---|
/camera/color/image_raw |
sensor_msgs/Image | RGB 图像 |
/camera/depth/image_rect_raw |
sensor_msgs/Image | 深度图 |
/velodyne_points |
sensor_msgs/PointCloud2 | 激光点云 |
/ detections_3d |
DetectionArray | 3D 检测结果 |
外参标定
标定板法(棋盘格 + 激光)
#!/usr/bin/env python3
"""相机-激光雷达外参标定"""
import numpy as np
import open3d as o3d
import cv2
from pathlib import Path
class CameraLidarCalibrator:
"""相机-激光雷达标定"""
def __init__(self, camera_intrinsics, resolution=(1920, 1080)):
self.K = camera_intrinsics # 内参矩阵
self.resolution = resolution
self.T_cam_lidar = None # 外参:激光雷达到相机的变换
def calibrate_with_board(
self,
lidar_points: np.ndarray,
board_corners_3d: np.ndarray,
image: np.ndarray
) -> np.ndarray:
"""
使用棋盘格标定板标定
Args:
lidar_points: 标定板上的激光点云 Nx3
board_corners_3d: 标定板3D角点(从相机视角计算)4x3
image: 相机图像
Returns:
T_lidar_cam: 4x4 激光雷达到相机的变换矩阵
"""
# 步骤1: 检测图像中的棋盘格角点
ret, img_corners = cv2.findChessboardCorners(
image, (9, 6), None
)
# 步骤2: 亚像素精化
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
img_corners = cv2.cornerSubPix(
cv2.cvtColor(image, cv2.COLOR_BGR2GRAY),
img_corners, (11, 11), (-1, -1), criteria
)
# 步骤3: PnP 求解相机位姿
object_points = np.zeros((9*6, 3), np.float32)
object_points[:, :2] = np.mgrid[:9, :6].T.reshape(-1, 2) * 0.04
_, rvec, tvec = cv2.solvePnP(
object_points, img_corners, self.K, None
)
R_cam_board, _ = cv2.Rodrigues(rvec)
# 步骤4: 找激光点在标定板上的坐标
# 标定板平面方程: ax + by + cz + d = 0
normal = R_cam_board[:, 2] # 标定板法向量
d = -normal @ (R_cam_board @ np.array([0, 0, 0]) + tvec.flatten())
# 将激光点投影到标定板平面
lidar_on_board = []
for pt in lidar_points:
t = -(normal @ pt + d) / (normal @ normal)
proj = pt + t * normal
lidar_on_board.append(proj)
lidar_on_board = np.array(lidar_on_board)
# 步骤5: ICP 匹配
# 变换到标定板坐标系
T_cam_board = np.eye(4)
T_cam_board[:3, :3] = R_cam_board
T_cam_board[:3, 3] = tvec.flatten()
T_board_cam = np.linalg.inv(T_cam_board)
lidar_in_board = (T_board_cam @ np.hstack([lidar_on_board, np.ones((len(lidar_on_board), 1))]).T).T
# ICP 求解变换
# ... 简化:使用 SVD 计算最优变换
return T_cam_lidar
def project_lidar_to_image(
self,
points: np.ndarray,
image: np.ndarray,
T_lidar_cam: np.ndarray
) -> np.ndarray:
"""将点云投影到图像"""
# 点云 -> 相机坐标系
points_cam = (T_lidar_cam @ np.hstack([points, np.ones((len(points), 1))]).T).T
# 过滤相机前方点
valid = points_cam[:, 2] > 0
points_cam = points_cam[valid]
# 投影到像素
uv = (self.K @ points_cam[:, :3].T).T
uv[:, 0] /= uv[:, 2]
uv[:, 1] /= uv[:, 2]
return uv[:, :2].astype(np.int32)
def calibrate_automatic(lidar_topic, image_topic):
"""自动标定方法(使用边缘/纹理对齐)"""
# 等待采集多帧数据后求解
pass
几何投影融合
LiDAR → 相机图像投影
import numpy as np
import open3d as o3d
from typing import Tuple, List
class LidarCameraProjector:
"""激光雷达点云投影到图像"""
def __init__(
self,
K: np.ndarray,
D: np.ndarray,
R: np.ndarray,
t: np.ndarray,
image_width: int,
image_height: int
):
"""
Args:
K: 相机内参 3x3
D: 畸变系数 5x1
R: 旋转矩阵 (lidar -> camera) 3x3
t: 平移向量 (lidar -> camera) 3x1
"""
self.K = K
self.D = D
self.R = R
self.t = t
self.width = image_width
self.height = image_height
# 构建投影矩阵
self.extrinsic = np.hstack([R, t])
# 畸变校正映射
self.map1, self.map2 = cv2.initUndistortRectifyMap(
K, D, np.eye(3), K, (image_width, image_height), cv2.CV_16SC2
)
def project(self, cloud: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""
将点云投影到图像平面
Args:
cloud: Nx3 点云 (lidar坐标系)
Retu
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл lidar-camera-fusion?
激光-相机融合技能 - 深度学习融合、几何投影融合、3D检测、ROS2标定与同步
Как установить скилл lidar-camera-fusion?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл lidar-camera-fusion запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…