2026-06-08 17:36:13 +08:00
|
|
|
|
#ifndef IMVSDEVICE_H
|
|
|
|
|
|
#define IMVSDEVICE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
|
|
// 设备传输层类型(参照 MVS CameraParams.h,统一暴露给上层)
|
|
|
|
|
|
enum class EMvsTLType
|
|
|
|
|
|
{
|
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
|
GigE,
|
|
|
|
|
|
USB3,
|
|
|
|
|
|
CameraLink,
|
|
|
|
|
|
Virtual,
|
|
|
|
|
|
Other,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 设备信息结构
|
|
|
|
|
|
struct MvsDeviceInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string serialNumber; // 序列号
|
|
|
|
|
|
std::string modelName; // 型号
|
|
|
|
|
|
std::string manufacturerName; // 厂商
|
|
|
|
|
|
std::string deviceVersion; // 设备版本
|
|
|
|
|
|
std::string userDefinedName; // 用户自定义名
|
|
|
|
|
|
std::string displayName; // 显示名(一般组合 model + sn)
|
|
|
|
|
|
std::string ipAddress; // 当前 IP(GigE)
|
|
|
|
|
|
std::string macAddress; // MAC(GigE)
|
|
|
|
|
|
EMvsTLType tlType{EMvsTLType::Unknown};
|
|
|
|
|
|
unsigned int width{0};
|
|
|
|
|
|
unsigned int height{0};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 图像数据结构(同 GalaxyDevice 风格)
|
|
|
|
|
|
struct MvsImageData
|
|
|
|
|
|
{
|
|
|
|
|
|
unsigned char* pData{nullptr}; // 图像数据指针
|
|
|
|
|
|
unsigned int width{0}; // 宽
|
|
|
|
|
|
unsigned int height{0}; // 高
|
|
|
|
|
|
unsigned int dataSize{0}; // 数据大小
|
|
|
|
|
|
int pixelFormat{0}; // 像素格式(enMvGvspPixelType 透传)
|
|
|
|
|
|
unsigned long long frameID{0}; // 帧号
|
|
|
|
|
|
unsigned long long timestamp{0}; // 时间戳(设备)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ROI
|
|
|
|
|
|
struct MvsROI
|
|
|
|
|
|
{
|
|
|
|
|
|
int offsetX{0};
|
|
|
|
|
|
int offsetY{0};
|
|
|
|
|
|
int width{0};
|
|
|
|
|
|
int height{0};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-29 13:59:12 +08:00
|
|
|
|
// Integer GenICam node metadata.
|
|
|
|
|
|
struct MvsIntFeatureInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
int64_t current{0};
|
|
|
|
|
|
int64_t minimum{0};
|
|
|
|
|
|
int64_t maximum{0};
|
|
|
|
|
|
int64_t increment{0};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct MvsFloatFeatureInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
double current{0.0};
|
|
|
|
|
|
double minimum{0.0};
|
|
|
|
|
|
double maximum{0.0};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class EMvsFeatureInterfaceType
|
|
|
|
|
|
{
|
|
|
|
|
|
Unknown = -1,
|
|
|
|
|
|
Value = 0,
|
|
|
|
|
|
Base = 1,
|
|
|
|
|
|
Integer = 2,
|
|
|
|
|
|
Boolean = 3,
|
|
|
|
|
|
Command = 4,
|
|
|
|
|
|
Float = 5,
|
|
|
|
|
|
String = 6,
|
|
|
|
|
|
Register = 7,
|
|
|
|
|
|
Category = 8,
|
|
|
|
|
|
Enumeration = 9,
|
|
|
|
|
|
EnumEntry = 10,
|
|
|
|
|
|
Port = 11,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class EMvsFeatureAccessMode
|
|
|
|
|
|
{
|
|
|
|
|
|
Unknown = -1,
|
|
|
|
|
|
NotImplemented = 0,
|
|
|
|
|
|
NotAvailable = 1,
|
|
|
|
|
|
WriteOnly = 2,
|
|
|
|
|
|
ReadOnly = 3,
|
|
|
|
|
|
ReadWrite = 4,
|
|
|
|
|
|
Undefined = 5,
|
|
|
|
|
|
CycleDetect = 6,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct MvsEnumEntryInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
unsigned int value{0};
|
|
|
|
|
|
std::string symbolic;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct MvsFeatureNodeInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
EMvsFeatureInterfaceType interfaceType{EMvsFeatureInterfaceType::Unknown};
|
|
|
|
|
|
EMvsFeatureAccessMode accessMode{EMvsFeatureAccessMode::Unknown};
|
|
|
|
|
|
int interfaceRet{0};
|
|
|
|
|
|
int accessRet{0};
|
|
|
|
|
|
int intInfoRet{0};
|
|
|
|
|
|
int enumInfoRet{0};
|
|
|
|
|
|
MvsIntFeatureInfo intInfo;
|
|
|
|
|
|
int64_t enumCurrent{0};
|
|
|
|
|
|
std::vector<MvsEnumEntryInfo> enumEntries;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-08 17:36:13 +08:00
|
|
|
|
// 图像回调签名
|
|
|
|
|
|
using MvsImageCallback = std::function<void(const MvsImageData&)>;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief IMvsDevice 接口类
|
|
|
|
|
|
*
|
|
|
|
|
|
* 海康威视 MVS SDK 的二次封装,提供与 GalaxyDevice 一致的 C++ 接口风格。
|
|
|
|
|
|
* 同一份头文件可用于 Windows 与 Linux/ARM aarch64。
|
|
|
|
|
|
*/
|
|
|
|
|
|
class IMvsDevice
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
virtual ~IMvsDevice() = default;
|
|
|
|
|
|
|
|
|
|
|
|
// 工厂
|
|
|
|
|
|
static int CreateObject(IMvsDevice** ppDevice);
|
|
|
|
|
|
|
|
|
|
|
|
// SDK 全局初始化(内部使用引用计数,可被多设备共享)
|
|
|
|
|
|
virtual int InitSDK() = 0;
|
|
|
|
|
|
virtual int UninitSDK() = 0;
|
|
|
|
|
|
virtual int GetSDKVersion(std::string& version) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 枚举(默认枚举 GigE + USB)
|
|
|
|
|
|
virtual int EnumerateDevices(std::vector<MvsDeviceInfo>& deviceList,
|
|
|
|
|
|
unsigned int tLayerType = 0) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 打开/关闭
|
|
|
|
|
|
virtual int OpenDevice(const std::string& serialNumber) = 0;
|
|
|
|
|
|
virtual int OpenDeviceByIndex(unsigned int index) = 0;
|
|
|
|
|
|
virtual int CloseDevice() = 0;
|
|
|
|
|
|
virtual bool IsDeviceOpen() = 0;
|
|
|
|
|
|
virtual int GetDeviceInfo(MvsDeviceInfo& info) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 触发/采集
|
|
|
|
|
|
virtual int SetTriggerMode(bool enable) = 0;
|
|
|
|
|
|
virtual int SendSoftTrigger() = 0;
|
|
|
|
|
|
virtual int StartAcquisition() = 0;
|
|
|
|
|
|
virtual int StopAcquisition() = 0;
|
|
|
|
|
|
virtual bool IsAcquisitioning() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 取流
|
|
|
|
|
|
virtual int CaptureImage(MvsImageData& image, unsigned int timeoutMs = 5000) = 0;
|
|
|
|
|
|
virtual int RegisterImageCallback(MvsImageCallback callback) = 0;
|
|
|
|
|
|
virtual int UnregisterImageCallback() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 图像参数
|
|
|
|
|
|
virtual int GetWidth(unsigned int& width) = 0;
|
|
|
|
|
|
virtual int GetHeight(unsigned int& height) = 0;
|
|
|
|
|
|
virtual int SetROI(const MvsROI& roi) = 0;
|
|
|
|
|
|
virtual int GetROI(MvsROI& roi) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 相机参数
|
|
|
|
|
|
virtual int SetExposureTime(double exposureTime) = 0;
|
|
|
|
|
|
virtual int GetExposureTime(double& exposureTime) = 0;
|
|
|
|
|
|
virtual int SetGain(double gain) = 0;
|
|
|
|
|
|
virtual int GetGain(double& gain) = 0;
|
|
|
|
|
|
virtual int SetFrameRate(double frameRate) = 0;
|
|
|
|
|
|
virtual int GetFrameRate(double& frameRate) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 通用特性访问(基于 GenICam Node Name)
|
|
|
|
|
|
virtual int SetIntFeature(const std::string& featureName, int64_t value) = 0;
|
|
|
|
|
|
virtual int GetIntFeature(const std::string& featureName, int64_t& value) = 0;
|
2026-06-29 13:59:12 +08:00
|
|
|
|
virtual int GetIntFeatureInfo(const std::string& featureName, MvsIntFeatureInfo& info) = 0;
|
|
|
|
|
|
virtual int GetFeatureNodeInfo(const std::string& featureName, MvsFeatureNodeInfo& info) = 0;
|
|
|
|
|
|
virtual int GetFloatFeatureInfo(const std::string& featureName, MvsFloatFeatureInfo& info) = 0;
|
2026-06-08 17:36:13 +08:00
|
|
|
|
virtual int SetFloatFeature(const std::string& featureName, double value) = 0;
|
|
|
|
|
|
virtual int GetFloatFeature(const std::string& featureName, double& value) = 0;
|
|
|
|
|
|
virtual int SetEnumFeature(const std::string& featureName, int64_t value) = 0;
|
2026-06-29 13:59:12 +08:00
|
|
|
|
virtual int SetEnumFeatureByString(const std::string& featureName, const std::string& value) = 0;
|
2026-06-08 17:36:13 +08:00
|
|
|
|
virtual int GetEnumFeature(const std::string& featureName, int64_t& value) = 0;
|
|
|
|
|
|
virtual int SetBoolFeature(const std::string& featureName, bool value) = 0;
|
|
|
|
|
|
virtual int GetBoolFeature(const std::string& featureName, bool& value) = 0;
|
|
|
|
|
|
virtual int SetStringFeature(const std::string& featureName, const std::string& value) = 0;
|
|
|
|
|
|
virtual int GetStringFeature(const std::string& featureName, std::string& value) = 0;
|
|
|
|
|
|
virtual int ExecuteCommand(const std::string& featureName) = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // IMVSDEVICE_H
|