|
@@ -1,6 +1,17 @@
|
|
|
#include "../pch/pch.h"
|
|
#include "../pch/pch.h"
|
|
|
#include "CDiandanAIShibieWorker.h"
|
|
#include "CDiandanAIShibieWorker.h"
|
|
|
#include "CChengzhongWorker.h"
|
|
#include "CChengzhongWorker.h"
|
|
|
|
|
+#include "../tool/CAppEnv.h"
|
|
|
|
|
+
|
|
|
|
|
+CDiandanAIShibieWorker::CDiandanAIShibieWorker()
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+CDiandanAIShibieWorker::~CDiandanAIShibieWorker()
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
//启动工作线程
|
|
//启动工作线程
|
|
|
void CDiandanAIShibieWorker::StartWork()
|
|
void CDiandanAIShibieWorker::StartWork()
|
|
@@ -39,46 +50,60 @@ void CDiandanAIShibieWorker::HandleDiandanAIShibie()
|
|
|
|
|
|
|
|
while (m_is_work == true)
|
|
while (m_is_work == true)
|
|
|
{
|
|
{
|
|
|
- if (m_is_ai_shibie == false)
|
|
|
|
|
- {
|
|
|
|
|
- //说明没开启AI识别,就等着
|
|
|
|
|
- Sleep(2000);
|
|
|
|
|
-
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- float weight = atof(CChengzhongWorker::GetInstance()->GetWeight().c_str());
|
|
|
|
|
- if (weight < -0.01)
|
|
|
|
|
|
|
+ try
|
|
|
{
|
|
{
|
|
|
- //说明没有重量,没放东西到秤上面,那么就不识别
|
|
|
|
|
- Sleep(100);
|
|
|
|
|
-
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //auto time_1 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
-
|
|
|
|
|
- m_ai_shibie_foodname = m_yoloFeatureManager.ClassFromVideoCapture();
|
|
|
|
|
-
|
|
|
|
|
- if (m_ai_shibie_foodname != "Unknown")
|
|
|
|
|
- {
|
|
|
|
|
- std::cout << "检测到类别: " << m_ai_shibie_foodname << std::endl;
|
|
|
|
|
|
|
+ if (m_is_ai_shibie == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //说明没开启AI识别,就等着
|
|
|
|
|
+ Sleep(2000);
|
|
|
|
|
+
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ float weight = atof(CChengzhongWorker::GetInstance()->GetWeight().c_str());
|
|
|
|
|
+ if (weight < -0.01)
|
|
|
|
|
+ {
|
|
|
|
|
+ //说明没有重量,没放东西到秤上面,那么就不识别
|
|
|
|
|
+ Sleep(100);
|
|
|
|
|
+
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //auto time_1 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //auto time_2 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
+
|
|
|
|
|
+ //auto duration_1 = std::chrono::duration_cast<std::chrono::milliseconds>(time_2 - time_1);
|
|
|
|
|
+ //std::wstring msg = L"摄像头识别耗时: " + std::to_wstring(duration_1.count()) + L" 毫秒";
|
|
|
|
|
+ //DEBUG_LOG(msg.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ //主线程里面去处理界面刷新
|
|
|
|
|
+ if (m_hwnd != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ ::SendMessage(m_hwnd, WM_AI_RECOGNITION_SUCCESS, 0, 0);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ catch (const std::exception& e)
|
|
|
{
|
|
{
|
|
|
- std::cout << "未检测到任何类别。" << std::endl;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //auto time_2 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
|
|
+ std::string aa = std::string(e.what());
|
|
|
|
|
+ DEBUG_LOG(("提取特征失败: " + std::string(e.what())).c_str());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //auto duration_1 = std::chrono::duration_cast<std::chrono::milliseconds>(time_2 - time_1);
|
|
|
|
|
- //std::wstring msg = L"摄像头识别耗时: " + std::to_wstring(duration_1.count()) + L" 毫秒";
|
|
|
|
|
- //DEBUG_LOG(msg.c_str());
|
|
|
|
|
|
|
+ //走到这里说明线程要退出了,做一些清理工作
|
|
|
|
|
+ CAppEnv::GetInstance()->DelWorkerNum();
|
|
|
|
|
|
|
|
- //主线程里面去处理界面刷新
|
|
|
|
|
- if (m_hwnd != NULL)
|
|
|
|
|
- {
|
|
|
|
|
- ::SendMessage(m_hwnd, WM_AI_RECOGNITION_SUCCESS, 0, 0);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ int b = 1;
|
|
|
}
|
|
}
|