feat: 改写GIGE协议

This commit is contained in:
2026-01-16 18:07:52 +08:00
parent ff4a4cabc8
commit 8b07397b5b
11 changed files with 321 additions and 97 deletions

View File

@@ -4,16 +4,18 @@
#include <QObject>
#include <QByteArray>
#include <QImage>
#include <QAtomicInt>
#include <cstdint>
// GVSP packet types
// GVSP packet types (GigE Vision 2.1 standard)
#define GVSP_LEADER_PACKET 0x01
#define GVSP_PAYLOAD_PACKET 0x02
#define GVSP_TRAILER_PACKET 0x03
#define GVSP_TRAILER_PACKET 0x02
#define GVSP_PAYLOAD_PACKET 0x03
// Payload types
#define PAYLOAD_TYPE_IMAGE 0x0001
#define PAYLOAD_TYPE_BINARY 0x0003
#define PAYLOAD_TYPE_IMAGE 0x0001
#define PAYLOAD_TYPE_BINARY 0x0003
#define PAYLOAD_TYPE_POINTCLOUD 0x8000 // Vendor-specific for point cloud data
// Image format
#define PIXEL_FORMAT_12BIT_GRAY 0x010C0001
@@ -24,11 +26,13 @@
#pragma pack(push, 1)
// GVSP packet header
// GVSP packet header (GigE Vision 2.1 standard - 8 bytes)
struct GVSPPacketHeader {
uint16_t status;
uint16_t block_id;
uint32_t packet_fmt_id;
uint16_t status; // Status flags
uint16_t block_id; // Block ID (frame number)
uint8_t packet_format; // Packet type: 0x01=Leader, 0x02=Trailer, 0x03=Payload
uint8_t reserved; // Reserved byte
uint16_t packet_id; // Packet ID within block
};
// Image data leader
@@ -71,6 +75,22 @@ struct GVSPBinaryDataTrailer {
uint32_t checksum;
};
// Point cloud data leader (vendor-specific, payload_type = 0x8000)
struct GVSPPointCloudDataLeader {
uint16_t reserved;
uint16_t payload_type; // 0x8000
uint32_t timestamp_high;
uint32_t timestamp_low;
uint32_t data_size; // Total size of point cloud data
};
// Point cloud data trailer
struct GVSPPointCloudDataTrailer {
uint32_t reserved;
uint16_t payload_type; // 0x8000
uint32_t checksum;
};
#pragma pack(pop)
class GVSPParser : public QObject
@@ -87,6 +107,7 @@ public:
signals:
void imageReceived(const QImage &image, uint32_t blockId);
void depthDataReceived(const QByteArray &depthData, uint32_t blockId);
void pointCloudDataReceived(const QByteArray &cloudData, uint32_t blockId);
void parseError(const QString &error);
private:
@@ -96,11 +117,12 @@ private:
void processImageData();
void processDepthData();
void processPointCloudData();
private:
// Reception state
bool m_isReceiving;
int m_dataType; // 0=unknown, 1=image, 3=depth
int m_dataType; // 0=unknown, 1=image, 3=depth, 4=pointcloud
uint32_t m_currentBlockId;
// Data buffer
@@ -116,6 +138,9 @@ private:
// Statistics
uint32_t m_lastBlockId;
int m_packetCount;
// Async processing control
QAtomicInt m_imageProcessingCount;
};
#endif // GVSPPARSER_H