#include "CameraImageHandler.h" #include "CameraMaterialGroupWnd/Group.h" CameraImageHandler::CameraImageHandler(int iCameraId) { captureAndConvertImage(iCameraId); } void CameraImageHandler::captureAndConvertImage(int iCameraId) { // CInterface interface; // ImageInfo image; // long result = interface.GrabImage(iCameraId, image); // if (result == 0) { // initGroup(iCameraId); // } m_pCViewInterface = ns_module::CViewInterface::GetInstance(); if (m_pCViewInterface == nullptr); { // 目前不做处理,为了兼容 } initGroup(iCameraId); // if (result == 0) { // qDebug() << "Image width: " << image.width; // qDebug() << "Image height: " << image.height; // QImage img; // // 根据图像格式转换 // switch (image.format) { // case GRAY8: // img = QImage(image.data, image.width, image.height, QImage::Format_Grayscale8); // break; // case RGB888: // img = QImage(image.data, image.width, image.height, QImage::Format_RGB888); // break; // case ARGB8888: // img = QImage(image.data, image.width, image.height, QImage::Format_ARGB32); // break; // case RGB32: // img = QImage(image.data, image.width, image.height, QImage::Format_RGB32); // break; // case YUV422: // break; // default: // qDebug() << "Unsupported image format"; // } // } else { // qDebug() << "Failed to grab image, error code: " << result; // } } Group* CameraImageHandler::getGroup() const { return m_pGroup; } Wafer* CameraImageHandler::getWafer() const{ return m_pWafer; } Waffle* CameraImageHandler::getWaffle() const{ return m_pWaffle; } MaterialBox* CameraImageHandler::getMaterialBox() const { return m_pMaterialBox; } Bond* CameraImageHandler::getBond() const { return m_pBond; } void CameraImageHandler::initGroup(int CameraId) { /** 这里面为什么又在Group 里面创建一个呢? ,不能同步? */ //CreateGroupData(); /* int CameraId, QString path, enum MaterialWindowType materialWindowType*/ QStringList dispmodel1; dispmodel1 << "P die align" << "D device align"; QStringList dispmodel2; dispmodel2 << "D device align" << "P die align"; QStringList dispmodel3; dispmodel3 << "B device align" << "P die align"; QStringList dispmodel4; dispmodel4 << "U die align" << "D device align"; if (CameraId == 1) { MaterialWindowType = 4; m_pBond = new Bond(0); if (m_pCViewInterface != nullptr) { std::vector stPointInfo; m_pCViewInterface->GetBondAllPointInfo(stPointInfo); m_pBond->UpdataVal(stPointInfo); } else { m_pBond->UpdataGenerateTestData(); } m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this); } else if (CameraId == 2) { MaterialWindowType = 2; m_pWaffle = new Waffle(0); if (m_pCViewInterface != nullptr) { std::vector veWaffle; //m_pCViewInterface->GetWafflePackAllPointInfo(veWaffle); m_pWaffle->UpdataVal(veWaffle); } else { m_pWaffle->UpdataGenerateTestData(); } m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this); } else if (CameraId == 3) { MaterialWindowType = 3; m_pMaterialBox = new MaterialBox(0); m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this); } else if (CameraId == 4) { MaterialWindowType = 1; m_pWafer = new Wafer(0); if (m_pCViewInterface != nullptr) { std::vector veWafer; m_pCViewInterface->GetWaferAllPointInfo(veWafer); m_pWafer->UpdataVal(veWafer); } else { m_pWafer->UpdataGenerateTestData(); } m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this); } else if (CameraId == 5) { MaterialWindowType = 1; m_pWafer = new Wafer(0); if (m_pCViewInterface != nullptr) { std::vector veWafer; m_pCViewInterface->GetWaferAllPointInfo(veWafer); m_pWafer->UpdataVal(veWafer); } else { m_pWafer->UpdataGenerateTestData(); } m_pGroup = new Group(CameraId, ":/images/test_image/image_1.png", MaterialWindowType, dispmodel1, this); } else if (CameraId == 6) { MaterialWindowType = 2; m_pWaffle = new Waffle(0); m_pGroup = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this); } else if (CameraId == 7) { MaterialWindowType = 3; m_pMaterialBox = new MaterialBox(0); m_pGroup = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this); } else if (CameraId == 8) { MaterialWindowType = 1; m_pWafer = new Wafer(0); m_pGroup = new Group(CameraId, ":/images/test_image/image_7.png", MaterialWindowType, dispmodel4, this); } else { m_pGroup = nullptr; // 如果 CameraId 不匹配,则 group 为 nullptr } } void CameraImageHandler::CreateGroupData(const CameraInfo& cameraInfo) { QString strPatch = R"(D:\config\MaterialInfo\)"; // 真实的路径 switch (cameraInfo.iCameraId) { case 0: //TODO: yang { strPatch += CreateMaterialType(cameraInfo.eType); } break; case 1: { strPatch += CreateMaterialType(cameraInfo.eType); } break; case 2: { strPatch += CreateMaterialType(cameraInfo.eType); } break; case 3: { strPatch += CreateMaterialType(cameraInfo.eType); } break; case 4: { strPatch += CreateMaterialType(cameraInfo.eType); } break; default: break; } //m_pGroup = new Group(cameraInfo, strPatch, this); } QString CameraImageHandler::CreateMaterialType(MATERIAL_TYPE materialType) { QString strLoadPatch; switch (materialType) { case MATERIAL_NULL: { } break; case MATERIAL_WAFER: { strLoadPatch = "Wafer"; m_pWafer = new Wafer(0); //TODO:以下传入指针实现同步? if (m_pCViewInterface != nullptr) { std::vector veWafer; m_pCViewInterface->GetWaferAllPointInfo(veWafer); m_pWafer->UpdataVal(veWafer); } else { m_pWafer->UpdataGenerateTestData(); } } break; case MATERIAL_WAFFLE: { strLoadPatch = "Waffle"; m_pWaffle = new Waffle(0); if (m_pCViewInterface != nullptr) { std::vector veWaffle; m_pCViewInterface->GetWafflePackAllPointInfo(veWaffle); m_pWaffle->UpdataVal(veWaffle); } else { m_pWaffle->UpdataGenerateTestData(); } } break; case MATERIAL_BOX: //-----------------------------未提供 { strLoadPatch = "MaterialBox"; m_pMaterialBox = new MaterialBox(0); } break; case MATERIAL_BOND: { strLoadPatch = "Bond"; m_pBond = new Bond(0); if (m_pCViewInterface != nullptr) { std::vector stPointInfo; m_pCViewInterface->GetBondAllPointInfo(stPointInfo); m_pBond->UpdataVal(stPointInfo); } else { m_pBond->UpdataGenerateTestData(); } } break; default: break; } return strLoadPatch; }