Vehicle_Road_Counter/src/videoService/video_pipeline.hpp

53 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <atomic>
#include <memory> // [新增] 用于 unique_ptr
#include <opencv2/opencv.hpp>
#include <string>
#include <thread>
#include <vector>
#include "spdlog/spdlog.h"
#include "yoloDetector/yolo_detector.hpp" // [新增] 包含检测器头文件 (同时也包含了 DetectionResult 定义)
// [删除] 移除此处定义的 DetectionResult直接使用 yolo_detector.hpp 中的定义
/*
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);
private:
std::atomic<bool> running_;
std::thread processingThread_;
// [新增] YOLO 检测器实例
std::unique_ptr<YoloDetector> detector_;
};