CameraImageHandler.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #include "CameraImageHandler.h"
  2. #include "CameraMaterialGroupWnd/Group.h"
  3. CameraImageHandler::CameraImageHandler(int iCameraId) {
  4. captureAndConvertImage(iCameraId);
  5. }
  6. void CameraImageHandler::captureAndConvertImage(int iCameraId) {
  7. // CInterface interface;
  8. // ImageInfo image;
  9. // long result = interface.GrabImage(iCameraId, image);
  10. // if (result == 0) {
  11. // initGroup(iCameraId);
  12. // }
  13. initGroup(iCameraId);
  14. // if (result == 0) {
  15. // qDebug() << "Image width: " << image.width;
  16. // qDebug() << "Image height: " << image.height;
  17. // QImage img;
  18. // // 根据图像格式转换
  19. // switch (image.format) {
  20. // case GRAY8:
  21. // img = QImage(image.data, image.width, image.height, QImage::Format_Grayscale8);
  22. // break;
  23. // case RGB888:
  24. // img = QImage(image.data, image.width, image.height, QImage::Format_RGB888);
  25. // break;
  26. // case ARGB8888:
  27. // img = QImage(image.data, image.width, image.height, QImage::Format_ARGB32);
  28. // break;
  29. // case RGB32:
  30. // img = QImage(image.data, image.width, image.height, QImage::Format_RGB32);
  31. // break;
  32. // case YUV422:
  33. // break;
  34. // default:
  35. // qDebug() << "Unsupported image format";
  36. // }
  37. // } else {
  38. // qDebug() << "Failed to grab image, error code: " << result;
  39. // }
  40. }
  41. Group* CameraImageHandler::getGroup() const {
  42. return m_pGroup;
  43. }
  44. Wafer* CameraImageHandler::getWafer() const{
  45. return m_pWafer;
  46. }
  47. Waffle* CameraImageHandler::getWaffle() const{
  48. return waffle;
  49. }
  50. MaterialBox* CameraImageHandler::getMaterialBox() const
  51. {
  52. return materialBox;
  53. }
  54. void CameraImageHandler::initGroup(int CameraId) {
  55. QStringList dispmodel1;
  56. dispmodel1 << "P die align" << "D device align";
  57. QStringList dispmodel2;
  58. dispmodel2 << "D device align" << "P die align";
  59. QStringList dispmodel3;
  60. dispmodel3 << "B device align" << "P die align";
  61. QStringList dispmodel4;
  62. dispmodel4 << "U die align" << "D device align";
  63. if (CameraId == 1)
  64. {
  65. MaterialWindowType = 1;
  66. m_pWafer = new Wafer(0);
  67. m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  68. }
  69. else if (CameraId == 2)
  70. {
  71. MaterialWindowType = 2;
  72. waffle = new Waffle(0);
  73. m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  74. }
  75. else if (CameraId == 3)
  76. {
  77. MaterialWindowType = 3;
  78. waffle = new Waffle(0);
  79. m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  80. }
  81. else if (CameraId == 4)
  82. {
  83. MaterialWindowType = 1;
  84. m_pWafer = new Wafer(0);
  85. m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  86. }
  87. else if (CameraId == 5)
  88. {
  89. MaterialWindowType = 1;
  90. m_pWafer = new Wafer(0);
  91. m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  92. }
  93. else if (CameraId == 6)
  94. {
  95. MaterialWindowType = 2;
  96. waffle = new Waffle(0);
  97. m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  98. }
  99. else if (CameraId == 7)
  100. {
  101. MaterialWindowType = 3;
  102. m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  103. }
  104. else if (CameraId == 8)
  105. {
  106. MaterialWindowType = 1;
  107. m_pWafer = new Wafer(0);
  108. m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  109. }
  110. else
  111. {
  112. m_pGroup = nullptr; // 如果 CameraId 不匹配,则 group 为 nullptr
  113. }
  114. }