#ifndef RTSPCAPTUREELEMENT_H
|
#define RTSPCAPTUREELEMENT_H
|
|
#include <basic/pipe/TimerElement.h>
|
#include <opencv2/opencv.hpp>
|
#include "../StructureApp/HiredisTool.h"
|
#include <atomic>
|
class RtspAnalysManager;
|
struct CvCapture_FFMPEG;
|
|
/**
|
* 使用ffmpeg封装的视频采集流水元素
|
* 输入,rtsp地址或文件(mp4或avi)路径,输出opencv中的cv::Mat
|
* 支持GPU硬解码
|
*/
|
class RtspCaptureElement: public TimerElement {
|
public:
|
RtspCaptureElement(const std::string& path,const std::string& camId, int fps = 30, int reOpenTime = -1, int gpuIndex = -1,RtspAnalysManager* manager= nullptr);
|
void SaveVideo(const std::string& strImageName);
|
void SetVideoMinMaxSeconds(const int minSeconds,const int maxSeconds);
|
private:
|
virtual void timerFunc() override;
|
virtual void threadInitial() override;
|
virtual void threadClosing() override;
|
void openVideo();
|
|
//
|
std::string MakeDir(const std::string& timeStamp);
|
private:
|
//用来抓取视频的Ffmpeg的封装类
|
CvCapture_FFMPEG* m_capture;
|
//保存视频流的路径,类似于rtsp://admin:a1234567@192.168.1.201:554/h264/ch2/main/av_stream
|
std::string m_path;
|
|
// Redis的工具类
|
HiredisTool m_redisTool;
|
|
//对保存到Redis的图片进行计数
|
std::atomic<int> m_picCount{0};
|
//GPU的索引
|
int m_gpuIndex;
|
|
//打开视频流失败的时候,sleep一段时间
|
int m_reopenTime;
|
|
//摄像机ID
|
std::string m_camId;
|
|
//用来保存录像视频的路径
|
std::string m_cutPath;
|
|
//几张图丢一张,目前是4张丢一张
|
const int m_nPicsPickOne = 8;
|
|
//每台摄像机保存到Redis的图片数量的最大值
|
const int M_CAM_PIC_MAX_COUNT = 50;
|
|
RtspAnalysManager * m_pManager;
|
};
|
|
#endif // VIDEOCAPTUREELEMENT_H
|