- 创建基本项目结构和目录 - 添加CMake构建系统 - 实现基础的配置解析功能 - 添加YOLO推理框架支持 - 集成RTSP和视频流处理功能 - 添加性能监控和日志系统
87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
#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
|