MvCamera.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /************************************************************************/
  2. /* 以C++接口为基础,对常用函数进行二次封装,方便用户使用 */
  3. /************************************************************************/
  4. #ifndef _MV_CAMERA_H_
  5. #define _MV_CAMERA_H_
  6. #include "MvCameraControl.h"
  7. #include <string.h>
  8. #ifdef MV_CAMERA_EXPORTS
  9. #define MV_CAMERA_DLL_API __declspec(dllexport)
  10. #else
  11. #define MV_CAMERA_DLL_API //__declspec(dllimport)
  12. #endif
  13. #ifndef MV_NULL
  14. #define MV_NULL 0
  15. #endif
  16. class CMvCamera
  17. {
  18. public:
  19. CMvCamera();
  20. ~CMvCamera();
  21. // ch:获取SDK版本号 | en:Get SDK Version
  22. static int GetSDKVersion();
  23. // ch:枚举设备 | en:Enumerate Device
  24. static int EnumDevices(unsigned int nTLayerType, MV_CC_DEVICE_INFO_LIST* pstDevList);
  25. // ch:判断设备是否可达 | en:Is the device accessible
  26. static bool IsDeviceAccessible(MV_CC_DEVICE_INFO* pstDevInfo, unsigned int nAccessMode);
  27. // ch:打开设备 | en:Open Device
  28. int Open(MV_CC_DEVICE_INFO* pstDeviceInfo);
  29. // ch:关闭设备 | en:Close Device
  30. int Close();
  31. // ch:判断相机是否处于连接状态 | en:Is The Device Connected
  32. bool IsDeviceConnected();
  33. // ch:注册图像数据回调 | en:Register Image Data CallBack
  34. int RegisterImageCallBack(void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), void* pUser);
  35. // ch:开启抓图 | en:Start Grabbing
  36. int StartGrabbing();
  37. // ch:停止抓图 | en:Stop Grabbing
  38. int StopGrabbing();
  39. // ch:主动获取一帧图像数据 | en:Get one frame initiatively
  40. int GetImageBuffer(MV_FRAME_OUT* pFrame, int nMsec);
  41. // ch:释放图像缓存 | en:Free image buffer
  42. int FreeImageBuffer(MV_FRAME_OUT* pFrame);
  43. // ch:显示一帧图像 | en:Display one frame image
  44. int DisplayOneFrame(MV_DISPLAY_FRAME_INFO* pDisplayInfo);
  45. // ch:设置SDK内部图像缓存节点个数 | en:Set the number of the internal image cache nodes in SDK
  46. int SetImageNodeNum(unsigned int nNum);
  47. // ch:获取设备信息 | en:Get device information
  48. int GetDeviceInfo(MV_CC_DEVICE_INFO* pstDevInfo);
  49. // ch:获取GEV相机的统计信息 | en:Get detect info of GEV camera
  50. int GetGevAllMatchInfo(MV_MATCH_INFO_NET_DETECT* pMatchInfoNetDetect);
  51. // ch:获取U3V相机的统计信息 | en:Get detect info of U3V camera
  52. int GetU3VAllMatchInfo(MV_MATCH_INFO_USB_DETECT* pMatchInfoUSBDetect);
  53. //设置相机曝光时间
  54. int SetExposureTime(IN float iExposureTime);
  55. //设置相机增益
  56. int SetGain(IN float iGain);
  57. // ch:获取和设置Int型参数,如 Width和Height,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  58. // en:Get Int type parameters, such as Width and Height, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  59. int GetIntValue(IN const char* strKey, OUT MVCC_INTVALUE_EX *pIntValue);
  60. int SetIntValue(IN const char* strKey, IN int64_t nValue);
  61. // ch:获取和设置Enum型参数,如 PixelFormat,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  62. // en:Get Enum type parameters, such as PixelFormat, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  63. int GetEnumValue(IN const char* strKey, OUT MVCC_ENUMVALUE *pEnumValue);
  64. int SetEnumValue(IN const char* strKey, IN unsigned int nValue);
  65. int SetEnumValueByString(IN const char* strKey, IN const char* sValue);
  66. // ch:获取和设置Float型参数,如 ExposureTime和Gain,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  67. // en:Get Float type parameters, such as ExposureTime and Gain, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  68. int GetFloatValue(IN const char* strKey, OUT MVCC_FLOATVALUE *pFloatValue);
  69. int SetFloatValue(IN const char* strKey, IN float fValue);
  70. // ch:获取和设置Bool型参数,如 ReverseX,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  71. // en:Get Bool type parameters, such as ReverseX, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  72. int GetBoolValue(IN const char* strKey, OUT bool *pbValue);
  73. int SetBoolValue(IN const char* strKey, IN bool bValue);
  74. // ch:获取和设置String型参数,如 DeviceUserID,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件UserSetSave
  75. // en:Get String type parameters, such as DeviceUserID, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  76. int GetStringValue(IN const char* strKey, MVCC_STRINGVALUE *pStringValue);
  77. int SetStringValue(IN const char* strKey, IN const char * strValue);
  78. // ch:执行一次Command型命令,如 UserSetSave,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  79. // en:Execute Command once, such as UserSetSave, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  80. int CommandExecute(IN const char* strKey);
  81. // ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
  82. int GetOptimalPacketSize(unsigned int* pOptimalPacketSize);
  83. // ch:注册消息异常回调 | en:Register Message Exception CallBack
  84. int RegisterExceptionCallBack(void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser);
  85. // ch:注册单个事件回调 | en:Register Event CallBack
  86. int RegisterEventCallBack(const char* pEventName, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser);
  87. // ch:强制IP | en:Force IP
  88. int ForceIp(unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay);
  89. // ch:配置IP方式 | en:IP configuration method
  90. int SetIpConfig(unsigned int nType);
  91. // ch:设置网络传输模式 | en:Set Net Transfer Mode
  92. int SetNetTransMode(unsigned int nType);
  93. // ch:像素格式转换 | en:Pixel format conversion
  94. int ConvertPixelType(MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam);
  95. // ch:保存图片 | en:save image
  96. int SaveImage(MV_SAVE_IMAGE_PARAM_EX* pstParam);
  97. // ch:保存图片为文件 | en:Save the image as a file
  98. int SaveImageToFile(MV_SAVE_IMG_TO_FILE_PARAM* pstParam);
  99. private:
  100. void* m_hDevHandle;
  101. };
  102. #endif//_MV_CAMERA_H_