50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
// video_service.h
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <opencv2/core/core.hpp>
|
|
#include <opencv2/videoio.hpp>
|
|
|
|
// 向前声明
|
|
template<typename T, typename IN, typename OUT>
|
|
class rknnPool;
|
|
class rkYolov5s;
|
|
|
|
class VideoService {
|
|
public:
|
|
VideoService(std::string model_path,
|
|
int thread_num,
|
|
std::string input_url, // <--- 新增
|
|
std::string output_rtsp_url); // <--- 名称修改,更明确
|
|
|
|
~VideoService(); // <-- 析构函数将用于调用 stop()
|
|
|
|
bool start();
|
|
void stop();
|
|
|
|
private:
|
|
void processing_loop();
|
|
|
|
// 配置
|
|
std::string model_path_;
|
|
int thread_num_;
|
|
std::string input_url_; // <--- 新增
|
|
std::string output_rtsp_url_; // <--- 新增
|
|
|
|
// 视频属性 (重要)
|
|
int frame_width_ = 0;
|
|
int frame_height_ = 0;
|
|
double frame_fps_ = 0.0;
|
|
|
|
// 资源
|
|
std::unique_ptr<rknnPool<rkYolov5s, cv::Mat, cv::Mat>> rknn_pool_;
|
|
cv::VideoCapture capture_;
|
|
cv::VideoWriter writer_;
|
|
|
|
// 线程管理
|
|
std::thread processing_thread_;
|
|
std::atomic<bool> running_{false};
|
|
}; |