CameraImageHandler.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. Bond* CameraImageHandler::getBond() const {
  55. return bond;
  56. }
  57. void CameraImageHandler::initGroup(int CameraId) {
  58. /* int CameraId, QString path, enum MaterialWindowType materialWindowType*/
  59. QStringList dispmodel1;
  60. dispmodel1 << "P die align" << "D device align";
  61. QStringList dispmodel2;
  62. dispmodel2 << "D device align" << "P die align";
  63. QStringList dispmodel3;
  64. dispmodel3 << "B device align" << "P die align";
  65. QStringList dispmodel4;
  66. dispmodel4 << "U die align" << "D device align";
  67. if (CameraId == 1)
  68. {
  69. MaterialWindowType = 4;
  70. bond = new Bond(0);
  71. m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  72. }
  73. else if (CameraId == 2)
  74. {
  75. MaterialWindowType = 2;
  76. waffle = new Waffle(0);
  77. m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  78. }
  79. else if (CameraId == 3)
  80. {
  81. MaterialWindowType = 3;
  82. waffle = new Waffle(0);
  83. m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  84. }
  85. else if (CameraId == 4)
  86. {
  87. MaterialWindowType = 1;
  88. m_pWafer = new Wafer(0);
  89. m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  90. }
  91. else if (CameraId == 5)
  92. {
  93. MaterialWindowType = 1;
  94. m_pWafer = new Wafer(0);
  95. m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  96. }
  97. else if (CameraId == 6)
  98. {
  99. MaterialWindowType = 2;
  100. waffle = new Waffle(0);
  101. m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  102. }
  103. else if (CameraId == 7)
  104. {
  105. MaterialWindowType = 3;
  106. m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  107. }
  108. else if (CameraId == 8)
  109. {
  110. MaterialWindowType = 1;
  111. m_pWafer = new Wafer(0);
  112. m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  113. }
  114. else
  115. {
  116. m_pGroup = nullptr; // 如果 CameraId 不匹配,则 group 为 nullptr
  117. }
  118. }