Vehicle_Road_Counter/src/videoService/video_pipeline.hpp

45 lines
957 B
C++
Raw Normal View History

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