ImageProvider.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef IMAGEPROVIDER_H
  2. #define IMAGEPROVIDER_H
  3. #include "EgoInterface.h"
  4. #include <QImage>
  5. #include <QQuickImageProvider>
  6. #include <mutex>
  7. #include"YOLOv5Detector.h"
  8. class ImageProvider : public QQuickImageProvider {
  9. public:
  10. ImageProvider();
  11. QImage requestImage(const QString &id, QSize *size,
  12. const QSize &requestedSize);
  13. QPixmap requestPixmap(const QString &id, QSize *size,
  14. const QSize &requestedSize);
  15. QImage img;
  16. };
  17. //摄像头视频数据展示到qt界面
  18. class ShowImage : public QObject, public IRender {
  19. Q_OBJECT
  20. public:
  21. explicit ShowImage(QObject *parent,RenderPosition _pos);
  22. ImageProvider *m_pImgProvider;
  23. virtual void OnRender(std::unique_ptr<uint8_t> &pBuffer, int32_t width,
  24. int32_t height) override;
  25. virtual void Empty() override;
  26. public slots:
  27. void sendFrontImage();
  28. void sendBackImage();
  29. void sendLeftImage();
  30. void sendRightImage();
  31. void sendLeftAnchor();
  32. void sendRightAnchor();
  33. // void sendPanelImage(QImage);
  34. signals:
  35. void callQmlRefeshFrontImg();
  36. void callQmlRefeshBackImg();
  37. void callQmlRefeshRightImg();
  38. void callQmlRefeshLeftImg();
  39. void callQmlRefeshLeftAnchor();
  40. void callQmlRefeshRightAnchor();
  41. void callQmlRefeshPanelImg();
  42. // void sendPic(QImage image);
  43. private:
  44. QImage m_image;
  45. RenderPosition campos;
  46. std::mutex buffer_lock_;
  47. YOLOv5Detector *detector;
  48. };
  49. #endif // IMAGEPROVIDER_H