MvGmslCamera.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. * 版权声明
  3. */
  4. #ifndef __MV_GMSL_CAMERA_H__
  5. #define __MV_GMSL_CAMERA_H__
  6. #include <cstdint>
  7. #ifdef MIIVII_NO_OPENCV
  8. #else
  9. #include <opencv2/opencv.hpp>
  10. #endif
  11. #include "MvGmslCameraVersion.h"
  12. #define CAMERA_NUM 8
  13. struct sync_out_a_cfg_client_t
  14. {
  15. uint8_t sync_camera_num; //sync access camera num
  16. uint8_t sync_freq; //sync camera frequency
  17. uint8_t sync_camera_bit_draw; //assign camera to sync
  18. uint8_t async_camera_num; //async access camera num
  19. uint8_t async_freq; //async camera frequency
  20. uint8_t async_camera_bit_draw; //assign camera to async
  21. uint8_t async_camera_pos[CAMERA_NUM];
  22. };
  23. typedef struct {
  24. std::string dev_node;
  25. std::string camera_fmt_str;
  26. std::string output_fmt_str;
  27. uint cam_w;
  28. uint cam_h;
  29. uint out_w;
  30. uint out_h;
  31. } camera_context_t;
  32. namespace miivii {
  33. class MvGmslCamera {
  34. public:
  35. /**
  36. * Init GMSL camera with input patameters.
  37. *
  38. *
  39. * @param[in] &devName Camera's device node name.
  40. * @param[in] camCount Number of cameras plugged into the device node.
  41. * @param[in] camWidth Single camera output width.
  42. * @param[in] camHeight Single camera output height.
  43. * @param[in] fps Frame rate(expressed in frames per second or FPS) .
  44. * @param[in] imgWidth Output image width.
  45. * @param[in] imgHeight Output image height.
  46. * @param[in] format Image format.
  47. *
  48. * The SDK makes it easy to convert the camera output resolution to customize output image resolution you want.
  49. * It uses the VIC(Video Image Compositor) for conversion, Therefore faster and more power-efficient.
  50. *
  51. * The GMSL-SDK supports following image format.
  52. * UYVY, VYUY, YUYV, YUV420M,
  53. * ABGR32, XBGR32, ARGB32.
  54. * The code bellow demonstrate how set the SDK for ABGR32 format image:
  55. * MvGmslCamera(_devName, 4, 1280, 720, 25, 1024, 576, string("ABGR32") );
  56. *
  57. */
  58. MvGmslCamera(struct sync_out_a_cfg_client_t camera_cfg);
  59. MvGmslCamera(camera_context_t *cam_ctx, uint32_t camCount, struct sync_out_a_cfg_client_t camera_cfg);
  60. /**
  61. * Terminate camera call.
  62. * */
  63. ~MvGmslCamera();
  64. /**
  65. * Get output RAW image.
  66. *
  67. * @param[in] *ppdata[] A pointer to get the image memory.
  68. * @param[out] timestamp[] The exact time when this photo exposured.
  69. *
  70. *
  71. * */
  72. bool GetImagePtr(uint8_t *ppdata[], uint64_t *timestamp,uint8_t camera_no);
  73. #ifdef MIIVII_NO_OPENCV
  74. #else
  75. /**
  76. * Get cv::Mat type output image.
  77. *
  78. * @param[in] outMat[] A mat array whose size corresponding to camera count.
  79. * @param[out] timestamp[] The exact time when the photos exposured.
  80. *
  81. * */
  82. bool GetImageCvMat(cv::Mat out_mat[], uint64_t *timestamp,uint8_t camera_no);
  83. #endif
  84. /**
  85. * Get output RAW image.
  86. *
  87. * @param[in] *ppdata[] A pointer to get the image memory.
  88. * @param[out] timestamp The exact time when this photo exposured.
  89. *
  90. *
  91. * */
  92. bool GetImagePtr(uint8_t *ppdata[], uint64_t &timestamp,uint8_t camera_no,std::string camera_dev);
  93. #ifdef MIIVII_NO_OPENCV
  94. #else
  95. /**
  96. * Get cv::Mat type output image.
  97. *
  98. * @param[in] outMat[] A mat array whose size corresponding to camera count.
  99. * @param[out] timestamp The exact time when the photos exposured.
  100. *
  101. * */
  102. bool GetImageCvMat(cv::Mat out_mat[], uint64_t &timestamp,uint8_t camera_no,std::string camera_dev);
  103. #endif
  104. /**
  105. * Get cv::Mat type output image.
  106. *
  107. * @param[in] CameraNum Camera namber.example:/dev/video1 CameraNum = 1
  108. * @param[out] &timestamp The exact time when the photos exposured.
  109. * The demo is in the cameras_opencv_demo.cpp
  110. * Getting the timestamp needs to be called after getting the image.
  111. * */
  112. bool GetGmslTimeStamp(const uint8_t CameraNum,uint64_t &timestamp);
  113. MvGmslCamera() = delete;
  114. MvGmslCamera(const MvGmslCamera &) = delete;
  115. MvGmslCamera &operator=(const MvGmslCamera &) = delete;
  116. private:
  117. void *handle_;
  118. };
  119. }
  120. #endif //__MV_GMSL_CAMERA_H__