/* * @Author: xiewenji 527774126@qq.com * @Date: 2025-09-03 10:33:48 * @LastEditors: xiewenji 527774126@qq.com * @LastEditTime: 2025-09-25 15:42:47 * @FilePath: /AI_SO_Test/AIEngineModule/src/AI_Factory.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ #include "AI_Factory.h" #include "AIModel_Impl.h" std::shared_ptr AIModel_Base::GetInstance() { std::shared_ptr instance = std::make_shared(); return instance; } AIFactory::AIFactory() { } AIFactory::~AIFactory() { } std::shared_ptr AIFactory::GetInstance() { static std::shared_ptr instance = std::make_shared(); return instance; } int AIFactory::InitALLAIModle(GPU_Config gupconfig) { if (gupconfig.GetNum() == 0) { printf("GPU Num Error \n"); return 1; } // 主检测 if (!AI_defect_NF) { AI_defect_NF = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "Base_detect"; boe_config.Stream_num = 2; AI_defect_NF->Init(boe_config); } // 黑白画面模型 if (!AI_defect_Type2) { AI_defect_Type2 = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_WTB.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "WTB_detect"; boe_config.Stream_num = 2; AI_defect_Type2->Init(boe_config); } // UP画面模型 if (!AI_defect_UP) { AI_defect_UP = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_UP.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "UP_detect"; boe_config.Stream_num = 2; AI_defect_UP->Init(boe_config); } // UP画面模型 if (!AI_defect_Chess) { AI_defect_Chess = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_CHESS.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "chess_detect"; boe_config.Stream_num = 2; AI_defect_Chess->Init(boe_config); } // 异显 if (!AI_defect_YX_1) { AI_defect_YX_1 = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_YX_L0.engine"; boe_config.strName = "YX1"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_YX_1->Init(boe_config); } if (!AI_defect_YX_2) { AI_defect_YX_2 = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_YX_L127L255.engine"; boe_config.strName = "YX2"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_YX_2->Init(boe_config); } // 分类 if (!AI_defect_Cls_L0) { AI_defect_Cls_L0 = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config jbl_config; jbl_config.gpuconfig.copy(gupconfig); jbl_config.strPath = "/home/aidlux/BOE/UseModel_FOG/class_14.engine"; jbl_config.inputType = AIModel_Base::Input_HWC; jbl_config.strName = "14_Class"; jbl_config.IsClass = true; AI_defect_Cls_L0->Init(jbl_config); } if (!AI_defect_Cls) { AI_defect_Cls = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config jbl_config; jbl_config.gpuconfig.copy(gupconfig); jbl_config.strPath = "/home/aidlux/BOE/UseModel_FOG/class_14.engine"; jbl_config.inputType = AIModel_Base::Input_HWC; jbl_config.strName = "old_Class"; jbl_config.IsClass = true; AI_defect_Cls->Init(jbl_config); } // 字符 检测 if (!AI_defect_zf) { AI_defect_zf = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_zf.engine"; boe_config.strName = "zf"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_zf->Init(boe_config); } // 标签 检测 if (!AI_defect_bq) { AI_defect_bq = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/FOG_tag.engine"; boe_config.strName = "bq"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_bq->Init(boe_config); } // 字符 127cell if (!AI_defect_127Cell) { AI_defect_127Cell = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_L127.engine"; boe_config.strName = "127Cell"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_127Cell->Init(boe_config); } // 精确检测 POL 异物 if (!AI_defect_RE_POL) { AI_defect_RE_POL = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/BOE_POL_128x128.engine"; boe_config.strName = "RE_POL"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_RE_POL->Init(boe_config); } // 精确检测 AD 异物 if (!AI_defect_RE_AD) { AI_defect_RE_AD = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/BOE_AD_128x128.engine"; boe_config.strName = "RE_POL"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_RE_AD->Init(boe_config); } // RGBHGRAY检测 if (!AI_defect_RE_RGBHGRAY) { AI_defect_RE_RGBHGRAY = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/FOG_RGBHGRAY.engine"; boe_config.strName = "RE_RGBHGRAY"; boe_config.inputType = AIModel_Base::Input_CHW; AI_defect_RE_RGBHGRAY->Init(boe_config); } // 边缘模型 if (!AI_defect_Edge_Big) { AI_defect_Edge_Big = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/Edge_Big.engine"; boe_config.strName = "Edge_Big"; boe_config.inputType = AIModel_Base::Input_HWC; AI_defect_Edge_Big->Init(boe_config); } if (!AI_defect_Edge_Samll) { AI_defect_Edge_Samll = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/Edge_Small.engine"; boe_config.inputType = AIModel_Base::Input_HWC; boe_config.strName = "Edge_Small"; AI_defect_Edge_Samll->Init(boe_config); } // 缺pol检测 if (!AI_defect_LackPol) { AI_defect_LackPol = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/BOE_LOSSPOL.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "BOE_LOSSPOL"; AI_defect_LackPol->Init(boe_config); } // 缺pol检测 if (!AI_defect_MarkLine) { AI_defect_MarkLine = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/defect_MARK_LINE.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "MarkLine"; AI_defect_MarkLine->Init(boe_config); } // 缺pol检测 if (!AI_defect_Edge_QX) { AI_defect_Edge_QX = AIModel_Base::GetInstance(); AIModel_Base::AIModelRun_Config boe_config; boe_config.gpuconfig.copy(gupconfig); boe_config.strPath = "/home/aidlux/BOE/UseModel_FOG/BOE_Edge_320x320.engine"; boe_config.inputType = AIModel_Base::Input_CHW; boe_config.strName = "Edge_QX"; AI_defect_Edge_QX->Init(boe_config); } m_bInitSucc = true; return 0; }