72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#ifndef CMVR_ES_ABSTRACT_CAMERA_H
|
|
#define CMVR_ES_ABSTRACT_CAMERA_H
|
|
#pragma once
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
#include "abstract_device.h"
|
|
|
|
namespace cmvr::device {
|
|
struct Rs2Intrinsics
|
|
{
|
|
float cx;
|
|
float cy;
|
|
float fx;
|
|
float fy;
|
|
float coeffs[5];
|
|
|
|
};
|
|
struct StreamFrameData
|
|
{
|
|
//原始图像数据
|
|
cv::Mat rgbImage;
|
|
//深度图原始数据
|
|
cv::Mat depthImage;
|
|
//彩色图像帧
|
|
std::vector<uint8_t> rgbFrame;
|
|
//深度图像帧
|
|
std::vector<uint8_t> depthFrame;
|
|
//编码格式
|
|
std::string codec = ".h264";
|
|
Rs2Intrinsics intrinsics;
|
|
int width;
|
|
int height;
|
|
int fps;
|
|
bool bKey;
|
|
bool depthKey;
|
|
};
|
|
class AbstractCamera : public AbstractDevice {
|
|
public:
|
|
// 录制状态
|
|
enum class RecordingState {
|
|
STOPPED,
|
|
RECORDING,
|
|
PAUSED
|
|
};
|
|
public:
|
|
explicit AbstractCamera(const XmlNode &cfg): AbstractDevice(cfg) {}
|
|
~AbstractCamera() override = default;
|
|
|
|
inline void getState(CameraState &state) {state = state_;}
|
|
virtual void getRGBImage(cv::Mat &color) {}
|
|
virtual void getDepthImage(cv::Mat &depth) {}
|
|
virtual void getRGBDImages(cv::Mat &color, cv::Mat &depth) {}
|
|
virtual void startRecording(const std::string &video_path) {}
|
|
virtual void stopRecording() {}
|
|
virtual void pauseRecording() {}
|
|
virtual void resumeRecording() {}
|
|
virtual void getEncodedFrame(StreamFrameData& frame_data, size_t& index) {}
|
|
|
|
virtual bool startStreaming() {return true;}
|
|
virtual void stopStreaming() {}
|
|
protected:
|
|
CameraState state_{};
|
|
void clear_error_() {
|
|
this->state_.is_error = false;
|
|
this->state_.error_message.clear();
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif // CMVR_ES_ABSTRACT_CAMERA_H
|