|
@@ -28,13 +28,10 @@
|
|
|
|
|
|
|
|
#include "../tool/CShuangpingTool.h"
|
|
#include "../tool/CShuangpingTool.h"
|
|
|
|
|
|
|
|
|
|
+#include "../worker/CDiandanAIShibieWorker.h"
|
|
|
|
|
+
|
|
|
CDiandanPageUI::CDiandanPageUI()
|
|
CDiandanPageUI::CDiandanPageUI()
|
|
|
{
|
|
{
|
|
|
- //默认先关闭
|
|
|
|
|
- m_is_ai_shibie = false;
|
|
|
|
|
-
|
|
|
|
|
- //创建一个新线程,专门处理AI识别的结果,避免因为AI识别的结果处理比较慢,导致界面卡顿
|
|
|
|
|
- std::thread(&CDiandanPageUI::HandleDiandanAIShibie, this).detach();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -67,6 +64,17 @@ void CDiandanPageUI::InitShow()
|
|
|
|
|
|
|
|
m_is_zidingyizhifu_init = true;
|
|
m_is_zidingyizhifu_init = true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //根据AI识别的设置,启动或者暂停AI识别【在进入点单页面的时候设置刚好合适】
|
|
|
|
|
+ std::string is_ai_shibie = CSetting::GetInstance()->GetParam("setting_is_ai_recognition_open");
|
|
|
|
|
+ if (is_ai_shibie == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ CDiandanAIShibieWorker::GetInstance()->StartAIShibie();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ CDiandanAIShibieWorker::GetInstance()->StopAIShibie();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CDiandanPageUI::RefreshShow()
|
|
void CDiandanPageUI::RefreshShow()
|
|
@@ -94,23 +102,27 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
m_foodtypeLayout->RemoveAll();
|
|
m_foodtypeLayout->RemoveAll();
|
|
|
|
|
|
|
|
std::string is_ai_shibie = CSetting::GetInstance()->GetParam("setting_is_ai_recognition_open");
|
|
std::string is_ai_shibie = CSetting::GetInstance()->GetParam("setting_is_ai_recognition_open");
|
|
|
|
|
+ if (is_ai_shibie == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_ai_shibie = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_ai_shibie = false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
CSqlite3 sqlite;
|
|
CSqlite3 sqlite;
|
|
|
m_nFoodpackageNum = sqlite.GetFoodpackageNum();
|
|
m_nFoodpackageNum = sqlite.GetFoodpackageNum();
|
|
|
m_types = sqlite.GetFoodtypes(); //只包含收银机显示的分类
|
|
m_types = sqlite.GetFoodtypes(); //只包含收银机显示的分类
|
|
|
|
|
|
|
|
- if (is_ai_shibie == "1")
|
|
|
|
|
|
|
+ if (m_is_ai_shibie == true)
|
|
|
{
|
|
{
|
|
|
m_cur_type_id = "ai";
|
|
m_cur_type_id = "ai";
|
|
|
-
|
|
|
|
|
- m_is_ai_shibie = true;
|
|
|
|
|
}
|
|
}
|
|
|
else if (m_nFoodpackageNum > 0)
|
|
else if (m_nFoodpackageNum > 0)
|
|
|
{
|
|
{
|
|
|
//默认选中的分类是商品套餐
|
|
//默认选中的分类是商品套餐
|
|
|
m_cur_type_id = "taocan";
|
|
m_cur_type_id = "taocan";
|
|
|
-
|
|
|
|
|
- m_is_ai_shibie = false;
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -119,8 +131,6 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
{
|
|
{
|
|
|
m_cur_type_id = m_types[0].id;
|
|
m_cur_type_id = m_types[0].id;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- m_is_ai_shibie = false;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
m_curFoodtypeOption = NULL;
|
|
m_curFoodtypeOption = NULL;
|
|
@@ -312,7 +322,7 @@ void CDiandanPageUI::InitFoodShow()
|
|
|
else if (m_cur_type_id == "ai")
|
|
else if (m_cur_type_id == "ai")
|
|
|
{
|
|
{
|
|
|
//把AI识别的结果展示出来
|
|
//把AI识别的结果展示出来
|
|
|
- std::string ai_name = m_ai_shibie_foodname;
|
|
|
|
|
|
|
+ std::string ai_name = CDiandanAIShibieWorker::GetInstance()->GetShibieFoodname();
|
|
|
if (ai_name == "Unknown" || ai_name == "")
|
|
if (ai_name == "Unknown" || ai_name == "")
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
@@ -3978,51 +3988,6 @@ void CDiandanPageUI::XianshiYouhui()
|
|
|
UpdateJiesuanZhifuPos();
|
|
UpdateJiesuanZhifuPos();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void CDiandanPageUI::HandleDiandanAIShibie()
|
|
|
|
|
-{
|
|
|
|
|
- std::wstring wsExePath = CSystem::getExePath();
|
|
|
|
|
- std::wstring wsProgramDir = CSystem::GetProgramDir();
|
|
|
|
|
-
|
|
|
|
|
- std::filesystem::path mainDir = wsProgramDir;
|
|
|
|
|
- std::string sMainDir = mainDir.string();
|
|
|
|
|
-
|
|
|
|
|
- std::string modelPath = sMainDir + "/ai/best_448.onnx"; // YOLO2026模型路径
|
|
|
|
|
- std::string databasePath = sMainDir + "/image_features.db"; // SQLite数据库路径
|
|
|
|
|
-
|
|
|
|
|
- std::cout << "=== YOLO2026图像检索系统 (SQLite-Vec版本) ===" << std::endl;
|
|
|
|
|
- std::cout << "模型路径: " << modelPath << std::endl;
|
|
|
|
|
- std::cout << "数据库路径: " << databasePath << std::endl;
|
|
|
|
|
- std::cout << "=========================================" << std::endl;
|
|
|
|
|
-
|
|
|
|
|
- // 初始化特征提取器
|
|
|
|
|
- std::cout << "正在初始化YOLO2026特征提取器..." << std::endl;
|
|
|
|
|
-
|
|
|
|
|
- m_yoloFeatureManager.loadModel(modelPath);
|
|
|
|
|
-
|
|
|
|
|
- while (true)
|
|
|
|
|
- {
|
|
|
|
|
- if (m_is_ai_shibie == false)
|
|
|
|
|
- {
|
|
|
|
|
- Sleep(1000);
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_ai_shibie_foodname = m_yoloFeatureManager.ClassFromVideoCapture();
|
|
|
|
|
-
|
|
|
|
|
- if (m_ai_shibie_foodname != "Unknown")
|
|
|
|
|
- {
|
|
|
|
|
- std::cout << "检测到类别: " << m_ai_shibie_foodname << std::endl;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- std::cout << "未检测到任何类别。" << std::endl;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //主线程里面去处理界面刷新
|
|
|
|
|
- ::SendMessage(m_pMainWnd->GetHWND(), WM_AI_RECOGNITION_SUCCESS, 0, 0);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void CDiandanPageUI::HandleDiandanAIShibieResult()
|
|
void CDiandanPageUI::HandleDiandanAIShibieResult()
|
|
|
{
|
|
{
|
|
|
if (m_cur_type_id == "ai")
|
|
if (m_cur_type_id == "ai")
|