GrabBag/Device/EpicEyeDevice/Inc/IEpicEyeDevice.h
2025-12-10 00:01:32 +08:00

203 lines
6.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef IEPICEYEDEVICE_H
#define IEPICEYEDEVICE_H
#include <iostream>
#include <string>
#include <vector>
#include <functional>
// 设备信息结构
struct EpicEyeDeviceInfo
{
std::string serialNumber; // 序列号
std::string ipAddress; // IP地址
std::string modelName; // 型号名称
std::string alias; // 别名
unsigned int width; // 图像宽度
unsigned int height; // 图像高度
};
// 点云数据结构
struct PointCloudData
{
float* pData; // 点云数据指针 (x, y, z 交替存储)
unsigned int width; // 点云宽度
unsigned int height; // 点云高度
unsigned int pointCount; // 点数 (width * height)
std::string frameID; // 帧ID
};
// 2D图像数据结构
struct ImageData2D
{
unsigned char* pData; // 图像数据指针
unsigned int width; // 图像宽度
unsigned int height; // 图像高度
unsigned int dataSize; // 数据大小
int pixelByteSize; // 像素字节大小
std::string frameID; // 帧ID
};
// 深度图数据结构
struct DepthData
{
float* pData; // 深度数据指针
unsigned int width; // 深度图宽度
unsigned int height; // 深度图高度
unsigned int dataSize; // 数据大小
std::string frameID; // 帧ID
};
// 相机内参结构
struct CameraIntrinsics
{
std::vector<float> cameraMatrix; // 相机矩阵 3x3
std::vector<float> distortion; // 畸变参数
};
/**
* @brief IEpicEyeDevice 接口类
* 封装 EpicEye SDK提供 3D 相机点云采集的 C++ 接口
*/
class IEpicEyeDevice
{
public:
virtual ~IEpicEyeDevice() = default;
/**
* @brief 创建设备对象
* @param ppDevice 设备对象指针
* @return 0-成功,其他-失败
*/
static int CreateObject(IEpicEyeDevice** ppDevice);
/**
* @brief 获取 SDK 版本
* @param version SDK版本字符串
* @return 0-成功,其他-失败
*/
virtual int GetSDKVersion(std::string& version) = 0;
/**
* @brief 搜索网络中的 EpicEye 相机
* @param deviceList 返回的设备列表
* @return 0-成功,其他-失败
*/
virtual int SearchCameras(std::vector<EpicEyeDeviceInfo>& deviceList) = 0;
/**
* @brief 通过 IP 地址连接相机
* @param ipAddress 相机 IP 地址
* @return 0-成功,其他-失败
*/
virtual int Connect(const std::string& ipAddress) = 0;
/**
* @brief 断开相机连接
* @return 0-成功,其他-失败
*/
virtual int Disconnect() = 0;
/**
* @brief 检查是否已连接
* @return true-已连接false-未连接
*/
virtual bool IsConnected() = 0;
/**
* @brief 获取已连接相机的设备信息
* @param deviceInfo 设备信息结构
* @return 0-成功,其他-失败
*/
virtual int GetDeviceInfo(EpicEyeDeviceInfo& deviceInfo) = 0;
/**
* @brief 触发拍摄一帧包含点云和2D图像
* @param frameID 返回的帧ID
* @param withPointCloud 是否包含点云数据默认true
* @return 0-成功,其他-失败
*/
virtual int TriggerCapture(std::string& frameID, bool withPointCloud = true) = 0;
/**
* @brief 获取点云数据
* @param frameID 帧ID由 TriggerCapture 返回)
* @param pointCloud 点云数据结构
* @return 0-成功,其他-失败
* @note 点云数据内存需要调用者释放
*/
virtual int GetPointCloud(const std::string& frameID, PointCloudData& pointCloud) = 0;
/**
* @brief 获取2D图像数据
* @param frameID 帧ID由 TriggerCapture 返回)
* @param image 图像数据结构
* @return 0-成功,其他-失败
* @note 图像数据内存需要调用者释放
*/
virtual int GetImage(const std::string& frameID, ImageData2D& image) = 0;
/**
* @brief 获取深度图数据
* @param frameID 帧ID由 TriggerCapture 返回)
* @param depth 深度图数据结构
* @return 0-成功,其他-失败
* @note 深度图数据内存需要调用者释放
*/
virtual int GetDepth(const std::string& frameID, DepthData& depth) = 0;
/**
* @brief 一次性获取点云数据(触发+获取)
* @param pointCloud 点云数据结构
* @param timeout 超时时间毫秒默认5000ms
* @return 0-成功,其他-失败
* @note 这是一个便捷方法,内部会自动调用 TriggerCapture 和 GetPointCloud
*/
virtual int CapturePointCloud(PointCloudData& pointCloud, unsigned int timeout = 5000) = 0;
/**
* @brief 一次性获取2D图像触发+获取)
* @param image 图像数据结构
* @param timeout 超时时间毫秒默认5000ms
* @return 0-成功,其他-失败
*/
virtual int CaptureImage(ImageData2D& image, unsigned int timeout = 5000) = 0;
/**
* @brief 获取相机内参
* @param intrinsics 相机内参结构
* @return 0-成功,其他-失败
*/
virtual int GetCameraIntrinsics(CameraIntrinsics& intrinsics) = 0;
/**
* @brief 获取相机配置JSON格式
* @param configJson 配置JSON字符串
* @return 0-成功,其他-失败
*/
virtual int GetConfig(std::string& configJson) = 0;
/**
* @brief 设置相机配置JSON格式
* @param configJson 配置JSON字符串
* @return 0-成功,其他-失败
*/
virtual int SetConfig(const std::string& configJson) = 0;
/**
* @brief 获取图像宽度
* @param width 图像宽度
* @return 0-成功,其他-失败
*/
virtual int GetWidth(unsigned int& width) = 0;
/**
* @brief 获取图像高度
* @param height 图像高度
* @return 0-成功,其他-失败
*/
virtual int GetHeight(unsigned int& height) = 0;
};
#endif // IEPICEYEDEVICE_H