76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
#pragma once
|
|
#ifndef RGBCAMERAOPERATION_H
|
|
#define RGBCAMERAOPERATION_H
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QDir>
|
|
#include <QDateTime>
|
|
#include <QCoreApplication>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <QImage>
|
|
|
|
#include <functional>
|
|
|
|
#include "imageProcessor.h"
|
|
|
|
typedef void(*func)();
|
|
|
|
class RgbCameraOperation:public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
RgbCameraOperation();
|
|
~RgbCameraOperation();
|
|
|
|
QImage m_qImage;
|
|
void setCallback(void(*func)());
|
|
|
|
// 保存图片和视频的公共接口
|
|
void saveImage(); // 保存当前帧为图片
|
|
void startVideoRecording(); // 开始视频录制
|
|
void stopVideoRecording(); // 停止视频录制
|
|
bool isRecording() const { return m_isRecording; } // 获取录制状态
|
|
|
|
private:
|
|
cv::Mat frame;
|
|
cv::VideoCapture *cam;
|
|
|
|
func m_func;
|
|
|
|
ImageProcessor* m_ImageProcessor;
|
|
|
|
bool record;
|
|
|
|
// 保存图片和视频相关
|
|
cv::VideoWriter* m_videoWriter;
|
|
bool m_isRecording;
|
|
int m_frameCounter;
|
|
|
|
// 定时器获取图像
|
|
QTimer* m_captureTimer;
|
|
// 定时器保存照片
|
|
QTimer* m_photoSaveTimer;
|
|
|
|
private slots:
|
|
void onCaptureFrame();
|
|
void onPhotoSaveTimeout();
|
|
|
|
Q_SIGNALS:
|
|
void PlotSignal();
|
|
void CamOpenedSignal();
|
|
void CamClosedSignal();
|
|
void VideoRecordingStartedSignal(); // 录制开始信号
|
|
void VideoRecordingStoppedSignal(); // 录制停止信号
|
|
void photoSavedSignal(const QString& filePath); // 照片保存成功信号
|
|
|
|
public slots:
|
|
void OpenCamera();
|
|
void OpenCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
|
void CloseCamera();
|
|
void startPhotoSaveTimer();
|
|
void stopPhotoSaveTimer();
|
|
};
|
|
#endif // !RGBCAMERAOPERATION_H
|