소스 정보
- 저장소
- MIUAV/vibe-coding-ros2
- 최근 소스 활동
- 2026년 4월 3일 16:37
- 감지된 SKILL.md 언어
- 중국어
- 스타
- 26
- 포크
- 2
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/MIUAV/vibe-coding-ros2 --skill yolo-detection명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | yolo-detection |
| description | YOLO 目标检测 ROS2 部署技能 - YOLOv5/v8/v11 TensorRT/OpenVINO/RKNN 部署 |
| argument-hint | YOLO OR 目标检测 OR TensorRT OR yolov8 OR object detection |
| user-invocable | true |
YOLO 系列目标检测网络的 ROS2 部署与优化
当需要以下帮助时使用此技能:
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <vision_msgs/msg/detection2_d_array.hpp>
#include <cv_bridge/cv_bridge.hpp>
#include <opencv2/opencv.hpp>
class YOLONode : public rclcpp::Node {
public:
YOLONode() : Node("yolo_node") {
// 加载模型
loadModel();
// 订阅图像
image_sub_ = this->create_subscription<sensor_msgs::msg::Image>(
"/camera/image_raw", 10,
std::bind(&YOLONode::imageCallback, this, std::placeholders::_1));
// 发布检测结果
det_pub_ = this->create_publisher<vision_msgs::msg::Detection2DArray>(
"/detections", 10);
}
private:
void loadModel() {
// TensorRT 引擎加载
// 初始化推理引擎
}
void imageCallback(const sensor_msgs::msg::Image::SharedPtr msg) {
cv::Mat image = cv_bridge::toCvShare(msg, "rgb8")->image;
// 预处理
auto input = preprocess(image);
// 推理
auto detections = infer(input);
// 后处理
auto results = postprocess(detections, image.size());
// 发布结果
publishResults(results);
}
cv::Mat preprocess(const cv::Mat& image) {
cv::Mat resized;
cv::resize(image, resized, cv::Size(640, 640));
resized.convertTo(resized, CV_32FC3, 1.0/255.0);
return resized;
}
std::vector<Detection> infer(const cv::Mat& input) {
// TensorRT 推理
}
std::vector<Detection> postprocess(std::vector<float>& output, cv::Size original_size) {
// NMS, 坐标转换
}
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr image_sub_;
rclcpp::Publisher<vision_msgs::msg::Detection2DArray>::SharedPtr det_pub_;
void* trt_context_;
};
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import Image
from vision_msgs.msg import Detection2DArray, Detection2D
from cv_bridge import CvBridge
import torch
import numpy as np
class YOLONode(Node):
def __init__(self):
super().__init__('yolo_node')
# 加载模型
self.model = torch.hub.load('ultralytics/yolov8', 'yolov8n')
self.bridge = CvBridge()
# 订阅图像
self.image_sub = self.create_subscription(
Image, '/camera/image_raw', self.callback, 10)
# 发布检测
self.det_pub = self.create_publisher(Detection2DArray, '/detections', 10)
def callback(self, msg):
# 转换图像
cv_image = self.bridge.imgmsg_to_cv2(msg, desired_encoding='rgb8')
# 推理
results = self.model(cv_image)
# 发布结果
.publish_detections(results, msg.header.stamp)
():
det_array = Detection2DArray()
det_array.header.stamp = stamp
box results.boxes:
det = Detection2D()
det.bbox.center.position.x = (box.xywh[])
det.bbox.center.position.y = (box.xywh[])
det.bbox.size_x = (box.xywh[])
det.bbox.size_y = (box.xywh[])
det_array.detections.append(det)
.det_pub.publish(det_array)
import torch
import tensorrt as trt
import numpy as np
class TensorRTInference:
def __init__(self, engine_path):
self.logger = trt.Logger(trt.Logger.WARNING)
self.runtime = trt.Runtime(self.logger)
with open(engine_path, 'rb') as f:
self.engine = self.runtime.deserialize_cuda_engine(f.read())
self.context = self.engine.create_execution_context()
self.buffers = {}
for i in range(self.engine.num_io_tensors):
name = self.engine.get_tensor_name(i)
self.buffers[name] = self.allocate_buffer(name)
def allocate_buffer(self, name):
shape = self.context.get_tensor_shape(name)
dtype = trt.nptype(self.engine.get_tensor_dtype(name))
size = np.prod(shape)
return torch.zeros(size, dtype=dtype, device='cuda')
def infer(self, input_data):
# 拷贝输入数据
self.buffers['input'].copy_(torch.from_numpy(input_data).cuda())
.context.execute_v2((.buffers.values()))
output = .buffers[].cpu().numpy()
output