feat: v0.1.0更新
This commit is contained in:
121
include/core/GVSPParser.h
Normal file
121
include/core/GVSPParser.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef GVSPPARSER_H
|
||||
#define GVSPPARSER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QImage>
|
||||
#include <cstdint>
|
||||
|
||||
// GVSP packet types
|
||||
#define GVSP_LEADER_PACKET 0x01
|
||||
#define GVSP_PAYLOAD_PACKET 0x02
|
||||
#define GVSP_TRAILER_PACKET 0x03
|
||||
|
||||
// Payload types
|
||||
#define PAYLOAD_TYPE_IMAGE 0x0001
|
||||
#define PAYLOAD_TYPE_BINARY 0x0003
|
||||
|
||||
// Image format
|
||||
#define PIXEL_FORMAT_12BIT_GRAY 0x010C0001
|
||||
|
||||
// Image dimensions
|
||||
#define IMAGE_WIDTH 1224
|
||||
#define IMAGE_HEIGHT 1024
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
// GVSP packet header
|
||||
struct GVSPPacketHeader {
|
||||
uint16_t status;
|
||||
uint16_t block_id;
|
||||
uint32_t packet_fmt_id;
|
||||
};
|
||||
|
||||
// Image data leader
|
||||
struct GVSPImageDataLeader {
|
||||
uint16_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t timestamp_high;
|
||||
uint32_t timestamp_low;
|
||||
uint32_t pixel_format;
|
||||
uint32_t size_x;
|
||||
uint32_t size_y;
|
||||
uint32_t offset_x;
|
||||
uint32_t offset_y;
|
||||
uint16_t padding_x;
|
||||
uint16_t padding_y;
|
||||
};
|
||||
|
||||
// Image data trailer
|
||||
struct GVSPImageDataTrailer {
|
||||
uint32_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t size_y;
|
||||
};
|
||||
|
||||
// Binary data leader (for depth data)
|
||||
struct GVSPBinaryDataLeader {
|
||||
uint16_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t timestamp_high;
|
||||
uint32_t timestamp_low;
|
||||
uint32_t file_size;
|
||||
uint32_t name_len;
|
||||
char file_name[256];
|
||||
};
|
||||
|
||||
// Binary data trailer
|
||||
struct GVSPBinaryDataTrailer {
|
||||
uint32_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t checksum;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class GVSPParser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GVSPParser(QObject *parent = nullptr);
|
||||
~GVSPParser();
|
||||
|
||||
void parsePacket(const QByteArray &packet);
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void imageReceived(const QImage &image, uint32_t blockId);
|
||||
void depthDataReceived(const QByteArray &depthData, uint32_t blockId);
|
||||
void parseError(const QString &error);
|
||||
|
||||
private:
|
||||
void handleLeaderPacket(const uint8_t *data, size_t size);
|
||||
void handlePayloadPacket(const uint8_t *data, size_t size);
|
||||
void handleTrailerPacket(const uint8_t *data, size_t size);
|
||||
|
||||
void processImageData();
|
||||
void processDepthData();
|
||||
|
||||
private:
|
||||
// Reception state
|
||||
bool m_isReceiving;
|
||||
int m_dataType; // 0=unknown, 1=image, 3=depth
|
||||
uint32_t m_currentBlockId;
|
||||
|
||||
// Data buffer
|
||||
QByteArray m_dataBuffer;
|
||||
size_t m_expectedSize;
|
||||
size_t m_receivedSize;
|
||||
|
||||
// Image info
|
||||
uint32_t m_imageWidth;
|
||||
uint32_t m_imageHeight;
|
||||
uint32_t m_pixelFormat;
|
||||
|
||||
// Statistics
|
||||
uint32_t m_lastBlockId;
|
||||
int m_packetCount;
|
||||
};
|
||||
|
||||
#endif // GVSPPARSER_H
|
||||
41
include/core/Logger.h
Normal file
41
include/core/Logger.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QMutex>
|
||||
|
||||
class Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Logger* instance();
|
||||
|
||||
void setLogFile(const QString &filePath);
|
||||
void setMaxLines(int maxLines);
|
||||
|
||||
void log(const QString &message);
|
||||
void debug(const QString &message);
|
||||
void info(const QString &message);
|
||||
void warning(const QString &message);
|
||||
void error(const QString &message);
|
||||
|
||||
private:
|
||||
explicit Logger(QObject *parent = nullptr);
|
||||
~Logger();
|
||||
|
||||
void writeLog(const QString &level, const QString &message);
|
||||
void checkAndTrimLog();
|
||||
|
||||
static Logger *s_instance;
|
||||
|
||||
QString m_logFilePath;
|
||||
int m_maxLines;
|
||||
QMutex m_mutex;
|
||||
int m_currentLines;
|
||||
};
|
||||
|
||||
#endif // LOGGER_H
|
||||
64
include/core/PointCloudProcessor.h
Normal file
64
include/core/PointCloudProcessor.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef POINTCLOUDPROCESSOR_H
|
||||
#define POINTCLOUDPROCESSOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <CL/cl.h>
|
||||
|
||||
class PointCloudProcessor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudProcessor(QObject *parent = nullptr);
|
||||
~PointCloudProcessor();
|
||||
|
||||
// 初始化OpenCL
|
||||
bool initializeOpenCL();
|
||||
|
||||
// 设置相机内参
|
||||
void setCameraIntrinsics(float fx, float fy, float cx, float cy);
|
||||
|
||||
// 设置Z缩放因子
|
||||
void setZScaleFactor(float scale);
|
||||
|
||||
// 将深度数据转换为点云(使用OpenCL GPU加速)
|
||||
void processDepthData(const QByteArray &depthData, uint32_t blockId);
|
||||
|
||||
signals:
|
||||
void pointCloudReady(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, uint32_t blockId);
|
||||
void errorOccurred(const QString &error);
|
||||
|
||||
private:
|
||||
// 清理OpenCL资源
|
||||
void cleanupOpenCL();
|
||||
|
||||
// 相机内参
|
||||
float m_fx;
|
||||
float m_fy;
|
||||
float m_cx;
|
||||
float m_cy;
|
||||
|
||||
// Z缩放因子
|
||||
float m_zScale;
|
||||
|
||||
// 图像尺寸
|
||||
int m_imageWidth;
|
||||
int m_imageHeight;
|
||||
int m_totalPoints;
|
||||
|
||||
// OpenCL资源
|
||||
cl_platform_id m_platform;
|
||||
cl_device_id m_device;
|
||||
cl_context m_context;
|
||||
cl_command_queue m_queue;
|
||||
cl_program m_program;
|
||||
cl_kernel m_kernel;
|
||||
cl_mem m_depthBuffer;
|
||||
cl_mem m_xyzBuffer;
|
||||
bool m_clInitialized;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDPROCESSOR_H
|
||||
Reference in New Issue
Block a user