CameraImageHandler.cpp 3.7 KB

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