MyCamera.h 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /************************************************************************/
  2. /* 以C++接口为基础,对常用函数进行二次封装,方便用户使用 */
  3. /************************************************************************/
  4. #ifndef _MY_CAMERA_H_
  5. #define _MY_CAMERA_H_
  6. #include <stdio.h>
  7. #include "MvCameraControl.h"
  8. class CMyCamera
  9. {
  10. public:
  11. CMyCamera();
  12. ~CMyCamera();
  13. static int EnumDevices(MV_CC_DEVICE_INFO_LIST* pstDevList);
  14. // ch:打开设备 | en:Open Device
  15. int Open(MV_CC_DEVICE_INFO* pstDeviceInfo);
  16. // ch:关闭设备 | en:Close Device
  17. int Close();
  18. // ch:开启抓图 | en:Start Grabbing
  19. int StartGrabbing();
  20. // ch:停止抓图 | en:Stop Grabbing
  21. int StopGrabbing();
  22. // ch:主动获取一帧图像数据 | en:Get one frame initiatively
  23. int GetOneFrameTimeout(unsigned char* pData, unsigned int* pnDataLen, unsigned int nDataSize, MV_FRAME_OUT_INFO_EX* pFrameInfo, int nMsec);
  24. // ch:设置显示窗口句柄 | en:Set Display Window Handle
  25. int Display(void* hWnd);
  26. // ch:保存图片 | en:save image
  27. int SaveImage(MV_SAVE_IMAGE_PARAM_EX* pstParam);
  28. // ch:注册图像数据回调 | en:Register Image Data CallBack
  29. int RegisterImageCallBack(void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser),
  30. void* pUser);
  31. // ch:注册消息异常回调 | en:Register Message Exception CallBack
  32. int RegisterExceptionCallBack(void(__stdcall* cbException)(unsigned int nMsgType, void* pUser),
  33. void* pUser);
  34. // ch:获取Int型参数,如 Width和Height,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  35. // en:Get Int type parameters, such as Width and Height, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  36. int GetIntValue(IN const char* strKey, OUT unsigned int *pnValue);
  37. int SetIntValue(IN const char* strKey, IN unsigned int nValue);
  38. // ch:获取Float型参数,如 ExposureTime和Gain,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  39. // en:Get Float type parameters, such as ExposureTime and Gain, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  40. int GetFloatValue(IN const char* strKey, OUT float *pfValue);
  41. int SetFloatValue(IN const char* strKey, IN float fValue);
  42. // ch:获取Enum型参数,如 PixelFormat,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  43. // en:Get Enum type parameters, such as PixelFormat, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  44. int GetEnumValue(IN const char* strKey, OUT unsigned int *pnValue);
  45. int SetEnumValue(IN const char* strKey, IN unsigned int nValue);
  46. // ch:获取Bool型参数,如 ReverseX,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  47. // en:Get Bool type parameters, such as ReverseX, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  48. int GetBoolValue(IN const char* strKey, OUT bool *pbValue);
  49. int SetBoolValue(IN const char* strKey, IN bool bValue);
  50. // ch:获取String型参数,如 DeviceUserID,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件UserSetSave
  51. // en:Get String type parameters, such as DeviceUserID, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  52. int GetStringValue(IN const char* strKey, IN OUT char* strValue, IN unsigned int nSize);
  53. int SetStringValue(IN const char* strKey, IN const char * strValue);
  54. // ch:执行一次Command型命令,如 UserSetSave,详细内容参考SDK安装目录下的 MvCameraNode.xlsx 文件
  55. // en:Execute Command once, such as UserSetSave, for details please refer to MvCameraNode.xlsx file under SDK installation directory
  56. int CommandExecute(IN const char* strKey);
  57. // ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
  58. int GetOptimalPacketSize();
  59. // 获取统计参数
  60. int GetAllMatchInfo(OUT unsigned int *nLostFrame, OUT unsigned int *nFrameCount);
  61. private:
  62. void* m_hDevHandle;
  63. public:
  64. unsigned char* m_pBufForSaveImage; // 用于保存图像的缓存
  65. unsigned int m_nBufSizeForSaveImage;
  66. unsigned char* m_pBufForDriver; // 用于从驱动获取图像的缓存
  67. unsigned int m_nBufSizeForDriver;
  68. };
  69. #endif