2025-12-31 16:30:10 +08:00
|
|
|
#pragma once
|
2025-12-24 16:14:25 +08:00
|
|
|
|
|
|
|
|
#include <atomic>
|
2025-12-31 16:30:10 +08:00
|
|
|
#include <opencv2/opencv.hpp>
|
2025-12-24 16:14:25 +08:00
|
|
|
#include <string>
|
|
|
|
|
#include <thread>
|
2025-12-31 16:30:10 +08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
|
|
|
|
|
// 模拟的检测结果结构体(对应未来的 YOLO 结果)
|
|
|
|
|
struct DetectionResult {
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
|
|
|
|
std::string label;
|
|
|
|
|
float confidence;
|
|
|
|
|
};
|
2025-12-24 16:14:25 +08:00
|
|
|
|
|
|
|
|
class VideoPipeline {
|
|
|
|
|
public:
|
|
|
|
|
VideoPipeline();
|
|
|
|
|
~VideoPipeline();
|
|
|
|
|
|
2025-12-31 16:30:10 +08:00
|
|
|
// 启动视频流处理
|
2025-12-24 16:14:25 +08:00
|
|
|
void Start(const std::string& inputUrl, const std::string& outputUrl);
|
2026-01-04 14:52:14 +08:00
|
|
|
void StartTest(const std::string& filePath, const std::string& outputUrl);
|
2025-12-24 16:14:25 +08:00
|
|
|
|
2025-12-31 16:30:10 +08:00
|
|
|
// 停止处理
|
2025-12-24 16:14:25 +08:00
|
|
|
void Stop();
|
|
|
|
|
|
|
|
|
|
private:
|
2026-01-04 14:52:14 +08:00
|
|
|
void processLoop(std::string inputUrl, std::string outputUrl, bool isFileSource);
|
2025-12-24 16:14:25 +08:00
|
|
|
|
2025-12-31 16:30:10 +08:00
|
|
|
// 占位算法函数:模拟推理
|
|
|
|
|
std::vector<DetectionResult> mockInference(const cv::Mat& frame);
|
2025-12-24 16:14:25 +08:00
|
|
|
|
2025-12-31 16:30:10 +08:00
|
|
|
// 绘图函数
|
|
|
|
|
void drawOverlay(cv::Mat& frame, const std::vector<DetectionResult>& results);
|
2025-12-24 16:14:25 +08:00
|
|
|
|
2025-12-31 16:30:10 +08:00
|
|
|
std::atomic<bool> running_;
|
|
|
|
|
std::thread processingThread_;
|
2025-12-24 16:14:25 +08:00
|
|
|
};
|