CameraImageHandler.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. void CameraImageHandler::initGroup(int CameraId) {
  49. QStringList dispmodel1;
  50. dispmodel1 << "P die align" << "D device align";
  51. QStringList dispmodel2;
  52. dispmodel2 << "D device align" << "P die align";
  53. QStringList dispmodel3;
  54. dispmodel3 << "B device align" << "P die align";
  55. QStringList dispmodel4;
  56. dispmodel4 << "U die align" << "D device align";
  57. if (CameraId == 1) {
  58. wafer = new Wafer(0);
  59. group = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  60. } else if (CameraId == 2) {
  61. MaterialWindowType = 2;
  62. group = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  63. } else if (CameraId == 3) {
  64. MaterialWindowType = 3;
  65. group = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  66. } else if (CameraId == 4) {
  67. wafer = new Wafer(0);
  68. group = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  69. } else if (CameraId == 5) {
  70. wafer = new Wafer(0);
  71. group = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this);
  72. } else if (CameraId == 6) {
  73. MaterialWindowType = 2;
  74. group = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
  75. } else if (CameraId == 7) {
  76. MaterialWindowType = 3;
  77. group = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
  78. } else if (CameraId == 8) {
  79. wafer = new Wafer(0);
  80. group = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this);
  81. } else {
  82. group = nullptr; // 如果 CameraId 不匹配,则 group 为 nullptr
  83. }
  84. }