104 lines
2.3 KiB
C++
104 lines
2.3 KiB
C++
#ifndef HXVIDEODEVICE_H
|
|
#define HXVIDEODEVICE_H
|
|
|
|
|
|
#include <QtConcurrent>
|
|
#include <QThread>
|
|
#include <QDateTime>
|
|
#include <QMap>
|
|
#include <QMutex>
|
|
|
|
#include "HxTaskDispatch.h"
|
|
|
|
#include "HxVideoDecoder.h"
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
//#include "HxMpp.h"
|
|
|
|
#if USE_ALGORITHM
|
|
#include "rga.h"
|
|
#include "im2d.hpp"
|
|
#endif
|
|
|
|
extern "C"
|
|
{
|
|
#include "libavformat/avformat.h"
|
|
}
|
|
|
|
using namespace cv;
|
|
using namespace std;
|
|
|
|
class HxVideoDevice : public QThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
HxVideoDevice(void);
|
|
void set(int type, QString address);
|
|
void set(int type, QString address, BsdWarnRegion region);
|
|
void set(bool status);
|
|
bool get_alarm_detection_timestamp(void);
|
|
QString snap(void);
|
|
|
|
QString build_image(int frame_id);
|
|
QString build_video(int frame_id);
|
|
|
|
void test(void);
|
|
|
|
private:
|
|
vector<uint8_t> compress(Mat frame, int quality);
|
|
QString snap(Mat frame);
|
|
QString snap(vector<uint8_t> data);
|
|
void recording_creation_task(void);
|
|
void video_frame_queue_check(void);
|
|
|
|
void video_frame_read_process(void);
|
|
void video_decoder_packet(AVPacket packet);
|
|
|
|
protected:
|
|
void run() override;
|
|
|
|
private:
|
|
int MvGetFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo);
|
|
int MvReleaseFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo);
|
|
int MvConvertImage(VideoFrameDataInfo *pSrcImageDataInfo, VideoFrameDataInfo *pDstImageDataInfo);
|
|
|
|
private:
|
|
int type;
|
|
int frame_id = 0;
|
|
QString address = "";
|
|
QDateTime alarm_detection_timestamp = QDateTime::currentDateTime();
|
|
bool detection_status = true;
|
|
|
|
QMutex record_queue_mutex;
|
|
QQueue<QString> record_queue;
|
|
|
|
VideoFrameDataInfo detect_frame_buffer;
|
|
VideoFrameDataInfo bgr_frame_buffer;
|
|
|
|
// QMutex video_frames_mutex;
|
|
// QQueue<Mat> video_frames;
|
|
|
|
QMutex video_frame_mutex;
|
|
Mat video_frame;
|
|
|
|
QMutex record_frames_mutex;
|
|
QMap<int, QString> record_frames;
|
|
|
|
int video_fps = 25;
|
|
int video_width = 0, video_height = 0;
|
|
int video_stream_index = 0;
|
|
bool connect_status;
|
|
AVFormatContext *ifmt_ctx;
|
|
|
|
HxVideoDecoder decoder;
|
|
|
|
// uint8_t *video_out_buffer = nullptr;
|
|
// struct SwsContext *video_sws_context = nullptr;
|
|
|
|
// AVCodecContext *video_dec_ctx = nullptr;
|
|
// AVFrame *video_dec_frame = nullptr, *video_picture_frame = nullptr;
|
|
};
|
|
|
|
#endif
|