rtsp_tensorrt/pipeline/common/pipeline.hpp
sladro e13cb3659c feat: 初始化项目结构
- 创建基本项目结构和目录
- 添加CMake构建系统
- 实现基础的配置解析功能
- 添加YOLO推理框架支持
- 集成RTSP和视频流处理功能
- 添加性能监控和日志系统
2024-12-24 16:25:03 +08:00

87 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <memory>
#include <string>
#include <thread>
#include <atomic>
#include <condition_variable>
#include "../input/input_manager.hpp"
#include "../inference/trt_inference.hpp"
#include "../render/renderer.hpp"
#include "../output/output_manager.hpp"
#include "config_parser.hpp"
namespace pipeline {
// 前向声明渲染器的DetectionResult避免命名冲突
namespace renderer {
struct DetectionResult;
}
class Pipeline {
public:
// 构造函数和析构函数
explicit Pipeline(const std::string& config_file, bool test_mode = false);
~Pipeline();
// 禁用拷贝
Pipeline(const Pipeline&) = delete;
Pipeline& operator=(const Pipeline&) = delete;
// 初始化Pipeline
bool init();
// 启动Pipeline
bool start();
// 停止Pipeline
void stop();
// 等待Pipeline结束
void wait();
// 获取Pipeline状态
bool isRunning() const { return running_; }
// 获取性能指标
bool getMetrics(PerformanceMetrics& metrics) const;
private:
// Pipeline主循环
void mainLoop();
// 处理一批数据
bool processBatch();
// 更新性能指标
void updateMetrics(float inference_time_ms);
private:
// 配置相关
std::string config_file_;
std::unique_ptr<ConfigParser> config_parser_;
PipelineConfig config_;
// 核心组件
std::unique_ptr<InputManager> input_manager_;
std::unique_ptr<TrtInference> inference_engine_;
std::unique_ptr<Renderer> renderer_;
std::unique_ptr<OutputManager> output_manager_;
// 线程控制
std::atomic<bool> running_{false};
std::atomic<bool> initialized_{false};
std::unique_ptr<std::thread> pipeline_thread_;
// 性能监控
mutable std::mutex metrics_mutex_;
PerformanceMetrics current_metrics_;
std::chrono::steady_clock::time_point last_fps_update_;
int frame_count_{0};
// 测试模式标志
bool test_mode_{false};
};
} // namespace pipeline