2023-03-19 16:44:12 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by tangchao on 2022/12/24.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|
|
|
|
|
#define XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QImage>
|
|
|
|
|
#include <opencv2/opencv.hpp>//包含了所有东西,编译很慢
|
2024-01-23 09:35:01 +08:00
|
|
|
|
#include "opencv2/imgproc/types_c.h"
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
|
#include <libavutil/opt.h>
|
|
|
|
|
#include "libavutil/pixfmt.h"
|
|
|
|
|
#include "libswscale/swscale.h"
|
|
|
|
|
#include <libavutil/imgutils.h>
|
|
|
|
|
#include <libavutil/avutil.h>
|
|
|
|
|
#include "libavdevice/avdevice.h"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Encode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Encode();
|
|
|
|
|
void initffmpeg(int width, int height);
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
AVCodecContext *avcodeccontext;
|
|
|
|
|
void savedata(AVFrame *frame);
|
|
|
|
|
void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, FILE *outfile);
|
|
|
|
|
AVPacket m_avpacket;
|
|
|
|
|
AVFrame *inpic;
|
|
|
|
|
AVFrame *outpic;
|
|
|
|
|
|
|
|
|
|
bool isinit;
|
|
|
|
|
int index1;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2023-03-19 16:44:12 +08:00
|
|
|
|
|
|
|
|
|
using namespace cv;
|
|
|
|
|
class rgbImage :public QObject
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
rgbImage(QWidget* pParent = NULL);
|
|
|
|
|
~rgbImage();
|
|
|
|
|
|
|
|
|
|
void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
|
|
|
|
|
void FillRgbImage(unsigned short *datacube);
|
|
|
|
|
void FillFocusGrayImage(unsigned short *datacube);
|
|
|
|
|
void FillFocusGrayQImage(unsigned short * datacube);
|
|
|
|
|
|
|
|
|
|
void FillOnerowofRgbImage(cv::Mat * matRgbImage, int rowNumber, unsigned short *datacube);
|
2024-01-23 09:35:01 +08:00
|
|
|
|
QImage Mat2QImage(cv::Mat cvImg);//https://www.cnblogs.com/annt/p/ant003.html
|
2023-03-19 16:44:12 +08:00
|
|
|
|
|
|
|
|
|
QImage *m_QRgbImage;
|
|
|
|
|
cv::Mat *m_matRgbImage;
|
2024-01-23 09:35:01 +08:00
|
|
|
|
QImage m_Qphoto;
|
2023-03-19 16:44:12 +08:00
|
|
|
|
|
|
|
|
|
QImage *m_qimageFocusGrayImage;
|
|
|
|
|
cv::Mat *m_matFocusGrayImage;//用于调焦时,显示一帧的灰度图
|
|
|
|
|
//cv::Mat m_matFocusGrayImage;//用于调焦时,显示一帧的灰度图
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CvVideoWriter *m_frame_writer;
|
|
|
|
|
VideoWriter m_VideoWriter;
|
|
|
|
|
// VideoWriter m_video("appsrc ! autovideoconvert ! filesink location=/media/nvme/delete/live.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));
|
|
|
|
|
// VideoWriter video("test.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//控制该填充rgb图像第几帧(行)数据
|
|
|
|
|
//以下两种情况需要重置为0:1)调用函数SetRgbImageWidthAndHeight;2)每次开始填充数据前
|
|
|
|
|
int m_iFrameCounter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int m_iFramerate;//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_iSampleNumber;//
|
|
|
|
|
int m_iBandNumber;//
|
|
|
|
|
|
|
|
|
|
int m_iFrameNumber;//
|
|
|
|
|
|
2024-01-23 09:35:01 +08:00
|
|
|
|
void initffmpeg();
|
|
|
|
|
|
2023-03-19 16:44:12 +08:00
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
signals :
|
|
|
|
|
void sendstr(QString str);
|
|
|
|
|
void sendstr1(QString str);
|
|
|
|
|
void refreslabelimg(QImage* img1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|