CameraItem.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #pragma once
  2. #include "preHeader.h"
  3. #include "IncCamera.h"
  4. #include "VideoStreamCatcher.h"
  5. #include <vector>
  6. #include <list>
  7. #include <cuda_runtime.h>
  8. #include "MfcLabel.h"
  9. #define CAMERAITEM_WIDTH 500
  10. #define CAMERAITEM_HEIGHT 500
  11. class CameraItem;
  12. typedef struct GpuData {
  13. unsigned char* pData{ nullptr };
  14. int nWidth;
  15. int nHeight;
  16. int nPitch;
  17. ~GpuData()
  18. {
  19. if (pData != nullptr)
  20. {
  21. cudaFree(pData);
  22. pData = nullptr;
  23. }
  24. }
  25. }GPU_DATA, * LPGPUDATA;
  26. typedef struct TagCameraRowGroup {
  27. //define a vector to record the
  28. std::list<CameraItem> CameraItemGroup;
  29. //define a vector to record the Row postion offset
  30. int nRowOffset{0};
  31. //define a vector to record the Col postion offset
  32. int nColOffset{0};
  33. //define a vector to record the Row Camera Index
  34. int nRowCameraIndex{0};
  35. //define a vector to record the Row Camera Count
  36. int nRowCameraCount{0};
  37. //define a Rect to record the Current Row Available Rect
  38. MfcLabel::Rect AvailableRect;
  39. //define a pointer to record the group that intersect with this group
  40. TagCameraRowGroup* pNextIntersectGroup{ nullptr };
  41. //define a 2d vector to record the overlap bounding
  42. std::vector<std::vector<int>> vvGroupOverlapBounding;
  43. TagCameraRowGroup()
  44. {
  45. CameraItemGroup.resize(0);
  46. }
  47. }TAG_CAM_ROW_GROUP,*LPTAG_CAM_ROW_GROUP;
  48. class CameraItem :public QObject,public QGraphicsItem
  49. {
  50. Q_OBJECT
  51. public:
  52. //set a constructor
  53. CameraItem(QGraphicsItem* parent);
  54. //set a constructor
  55. CameraItem();
  56. ~CameraItem();
  57. CameraItem(const CameraItem& other);
  58. //init the CameraItem with the position
  59. bool Init(int nIndex,QPointF Pos);
  60. //boundingrect
  61. QRectF boundingRect() const;
  62. void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
  63. //mouse press event process slots
  64. void mousePressEvent(QGraphicsSceneMouseEvent* event);
  65. //set a signal to indicate the mouse is pressed
  66. signals:
  67. void CameraItemPressed(CameraItem* pItem);
  68. public:
  69. //Current Item position
  70. QPointF CurrentPos;
  71. //indicate the item is selected or not
  72. bool bSelected;
  73. //current item index
  74. int nItemColIndex;
  75. //current item row index
  76. int nItemRowIndex;
  77. CAMERA_INFO m_CameraInfo;
  78. //set a VideoStreamCatcher to catch the video stream
  79. VideoStreamCatcher m_VideoStreamCatcher;
  80. QRect ImageRect;
  81. //set attribute to indicate the item is intersect rect
  82. //when copy the image to pano image buffer,use this attribute to judge whether need to copy
  83. //this attribute only indicate the item itself has been overlap apart,not the other item
  84. //this Intersectrect is in pano intersect with right
  85. QRect IntersectRect;
  86. //this intersectrect is in this coordinate,intersect with left
  87. QRect PreIntersectRect;
  88. std::vector<std::vector<int>> m_vvOverlapBounding;
  89. CameraItem* pIntersectInstance;
  90. //define a cv::mat to store Current frame
  91. cv::Mat m_CurrentFrame;
  92. //设置一个真正的不变的指针,防止保存在工单内的指针失效
  93. GPU_DATA m_CurrentGpuData;
  94. //define a bool to indicate the item is active or not
  95. bool bActive;
  96. unsigned char* pCurrentFrame{nullptr};
  97. static bool* pCameraItemModified;
  98. };
  99. Q_DECLARE_METATYPE(CameraItem*);