EntityCamera.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #pragma once
  2. #include "Camera_Global.h"
  3. #include "../../Common/CameraBaseClass/IBaseCamCommon.h"
  4. #include "../../Common/CameraBaseClass/IBaseCamera.h"
  5. #include "CamParamConfig.h"
  6. #include "DialogCamPasram.h"
  7. //////////////////////////////////////////////////////////////////////////
  8. #include "GenICam/System.h"
  9. #include "GenICam/Camera.h"
  10. #include "GenICam/GigE/GigECamera.h"
  11. #include "GenICam/GigE/GigEInterface.h"
  12. #include "Infra/PrintLog.h"
  13. #include "Memory/SharedPtr.h"
  14. using namespace Dahua;
  15. /// ENTITY相机接口类
  16. class ICamera : public IBaseCamera
  17. {
  18. public:
  19. /// 初始化相机环境
  20. static bool initEnv();
  21. /// 关闭相机环境
  22. static bool closeEnv();
  23. /// 获取所有相机序列号
  24. static QVector<QString> cameraSerial();
  25. public:
  26. Dahua::GenICam::IAcquisitionControlPtr sptrAcquisitionControl;
  27. Dahua::GenICam::IStreamSourcePtr streamPtr;
  28. Dahua::GenICam::ICameraPtr m_pCamera;
  29. };
  30. class EntityCamera : public ICamera
  31. {
  32. private:
  33. EntityCamera();
  34. ~EntityCamera(void);
  35. CamParamConfig* m_pCamParamConfig; //配置参数类
  36. class DialogCamPasram* m_pDialogCamPasram; //相机参数设置窗口
  37. public:
  38. static EntityCamera* createCamera(QString serial);
  39. public:
  40. /// 获取配置参数类
  41. virtual IBaseCamParamConfig* camParamConfig();
  42. protected:
  43. /// 打开相机
  44. bool openCamera(QString serial);
  45. /// 关闭相机
  46. bool closeCamera();
  47. /// 初始化
  48. bool initialize();
  49. private:
  50. /// 加载参数
  51. virtual void loadCamParam();
  52. /// 保存参数
  53. virtual void saveCamParam();
  54. /// 设置相机工作模式
  55. virtual bool setWorkMode(IBaseCamCommon::CamWorkMode, bool Running = false) ;
  56. /// 相机工作模式
  57. virtual IBaseCamCommon::CamWorkMode workMode() ;
  58. /// 相机开始工作
  59. virtual bool startWork() ;
  60. /// 相机停止工作
  61. virtual bool stopWork() ;
  62. /// 相机序列号
  63. virtual QString serial() ;
  64. /// 重启相机
  65. virtual bool restartCamera() ;
  66. /// 获取一桢图像
  67. virtual bool captureImage(void** buf, int size) ;
  68. /// 获取图像宽
  69. virtual int imageWidth(void) ;
  70. /// 获取图像高
  71. virtual int imageHeight(void) ;
  72. /// 获取图像通道数
  73. virtual int imageChannels(void) ;
  74. /// 显示设置参数窗口页面
  75. virtual void showParamConfigWindow(int mode = 0) ;
  76. /// 获取相机最大分辨率
  77. virtual bool getMaxSize(int& w, int& h) ;
  78. /// 设置相机分辨率
  79. virtual bool setResolution(int w, int h) ;
  80. /// 获取已注册图像回调的数量
  81. virtual int getReceCallBackSIze();
  82. ///设置接收图像数据回调函数
  83. virtual void setReceCallBack(IBaseCamCommon::receImgCallBack callBack, long long userParam, QString userID = "main") ;
  84. ///设置接收Log数据回调函数
  85. virtual void setReceLogCallBack(IBaseCamCommon::receLogCallBack callBack, long long userParam) ;//设置接收数据回调函数
  86. /// 软件触发采图
  87. virtual void softTriggerCap(QString userID = "main") ;
  88. private:
  89. int m_nImageChannels;
  90. QString m_strSerial;
  91. IBaseCamCommon::CamWorkMode mWorkMode; //工作模式
  92. long long mUserParam; //回调函数用户自定义参数
  93. long long mLogUserParam; //回调Log函数用户自定义参数
  94. QString m_strUserID;
  95. IBaseCamCommon::CamImgData mImgCapBuffer;//捕获图像缓存
  96. QVector <IBaseCamCommon::ImgCallBack*> m_pImgCallBack;//接收数据回调函数
  97. private:
  98. static void onGetFrame(const Dahua::GenICam::CFrame& pFrame, const void* pUser);
  99. public:
  100. private:
  101. //接收数据回调函数
  102. //IBaseCamCommon::receImgCallBack m_pReceImgFunction;
  103. //接收Log回调函数
  104. IBaseCamCommon::receLogCallBack m_pReceLogFunction;
  105. /// 执行回调函数
  106. void execCallFunction(IBaseCamCommon::CamImgData*, int frameCount);
  107. /// 执行Log回调函数
  108. void execLogCallFunction(QString serial, QString Massage, long long userParam);
  109. /// 设置连续采集图像
  110. bool setToFreeRunMode();
  111. /// 设置软件触发模式采图
  112. bool setToSoftwareTrigerMode();
  113. /// 设置硬件触发
  114. bool setToHardwareTrigerMode();
  115. };