mv_camera.h 6.0 KB

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