张洋 4 weeks ago
parent
commit
cc4be16427

+ 5 - 5
zhipuzi_pos_windows/page/CAIxuexiPageUI.cpp

@@ -548,6 +548,11 @@ void CAIxuexiPageUI::UpdateVideoShow()
 	return;
 }
 
+void CAIxuexiPageUI::StopVideoThread()
+{
+	m_is_video_thread_run = false;
+}
+
 void CAIxuexiPageUI::ClickFoodAction()
 {
 	//点击普通商品之后的处理逻辑
@@ -677,9 +682,4 @@ void CAIxuexiPageUI::DoXuexi()
 	pItem->SetImagePath(imagePath);
 
 	pXuexiScrollLayout->Add(pItem);
-}
-
-void CAIxuexiPageUI::StopVideoThread()
-{
-	m_is_video_thread_run = false;
 }

+ 3 - 2
zhipuzi_pos_windows/page/CAIxuexiPageUI.h

@@ -57,6 +57,9 @@ public:
 
 	void UpdateVideoShow();
 
+	//暂停摄像头线程
+	void StopVideoThread();
+
 	//点击某一个商品的item之后的处理逻辑
 	void ClickFoodAction();
 
@@ -71,8 +74,6 @@ public:
 	//点击拍摄并学习按钮之后的处理逻辑
 	void DoXuexi();
 
-	void StopVideoThread();
-
 private:
 	bool m_is_video_thread_run = false;
 	HBITMAP m_hBitmap;

+ 4 - 24
zhipuzi_pos_windows/tool/CAppEnv.cpp

@@ -54,27 +54,19 @@ void CAppEnv::Stop()
 	//停止打印任务
 	CPosPrinterWorker::GetInstance()->Stop();
 
-	auto time_2 = std::chrono::high_resolution_clock::now();
-
 	//停止称重任务
 	CChengzhongWorker::GetInstance()->Stop();
 
-	auto time_3 = std::chrono::high_resolution_clock::now();
-
 	//停止声音任务
 	CVoiceWorker::GetInstance()->Stop();
 
-	auto time_4 = std::chrono::high_resolution_clock::now();
-
 	//暂停AI识别任务
 	CDiandanAIShibieWorker::GetInstance()->Stop();
-
-	auto time_5 = std::chrono::high_resolution_clock::now();
 	
 	//停止通用任务
 	CCommonWorker::GetInstance()->Stop();
 
-	auto time_6 = std::chrono::high_resolution_clock::now();
+	auto time_2 = std::chrono::high_resolution_clock::now();
 
 	//必须等所有工作线程都退出了,才能走到这里,否则可能会有一些线程还在访问已经被销毁的资源,导致崩溃
 	while (m_worker_count > 0)
@@ -83,25 +75,13 @@ void CAppEnv::Stop()
 		Sleep(10);
 	}
 
-	auto time_8 = std::chrono::high_resolution_clock::now();
+	auto time_3 = std::chrono::high_resolution_clock::now();
 
 	auto duration1 = std::chrono::duration_cast<std::chrono::milliseconds>(time_2 - time_1);
-	CLewaimaiLog::OutputDebugMessage(("打印任务耗时: " + std::to_string(duration1.count()) + " 毫秒").c_str());
+	CLewaimaiLog::OutputDebugMessage(("Stop 耗时: " + std::to_string(duration1.count()) + " 毫秒").c_str());
 
 	auto duration2 = std::chrono::duration_cast<std::chrono::milliseconds>(time_3 - time_2);
-	CLewaimaiLog::OutputDebugMessage(("称重任务耗时: " + std::to_string(duration2.count()) + " 毫秒").c_str());
-
-	auto duration3 = std::chrono::duration_cast<std::chrono::milliseconds>(time_4 - time_3);
-	CLewaimaiLog::OutputDebugMessage(("声音任务耗时: " + std::to_string(duration3.count()) + " 毫秒").c_str());
-
-	auto duration5 = std::chrono::duration_cast<std::chrono::milliseconds>(time_5 - time_4);
-	CLewaimaiLog::OutputDebugMessage(("AI识别任务耗时: " + std::to_string(duration5.count()) + " 毫秒").c_str());
-
-	auto duration6 = std::chrono::duration_cast<std::chrono::milliseconds>(time_6 - time_5);
-	CLewaimaiLog::OutputDebugMessage(("通用任务耗时: " + std::to_string(duration6.count()) + " 毫秒").c_str());
-
-	auto duration7 = std::chrono::duration_cast<std::chrono::milliseconds>(time_8 - time_1);
-	CLewaimaiLog::OutputDebugMessage(("总耗时: " + std::to_string(duration7.count()) + " 毫秒").c_str());
+	CLewaimaiLog::OutputDebugMessage(("等待线程退出耗时: " + std::to_string(duration2.count()) + " 毫秒").c_str());
 }
 
 void CAppEnv::AddWorkerNum()

+ 4 - 4
zhipuzi_pos_windows/tool/CVideoCapture.cpp

@@ -68,8 +68,8 @@ void CVideoCapture::InitVideoCapture()
 	1280×720(720p HD):标准高清分辨率,广泛用于人脸识别、目标检测等视觉任务
 	1920×1080(1080p Full HD):全高清分辨率,提供高质量图像,适用于高精度视觉分析
 	*/
-	int width = 1920;
-	int height = 1080;
+	int width = 640;
+	int height = 480;
 
 	m_cap.set(cv::CAP_PROP_FRAME_WIDTH, width);
 	m_cap.set(cv::CAP_PROP_FRAME_HEIGHT, height);
@@ -85,9 +85,9 @@ void CVideoCapture::InitVideoCapture()
 
 	// ========== 关键硬件参数:解决反光过曝发白 ==========
 	// 1. 关闭自动曝光(必须,否则强光自动提亮加重发白)
-	m_cap.set(cv::CAP_PROP_AUTO_EXPOSURE, 0);
+	m_cap.set(cv::CAP_PROP_AUTO_EXPOSURE, 1);
 	// 2. 手动降低曝光值,数值越小进光越少,根据相机微调
-	m_cap.set(cv::CAP_PROP_EXPOSURE, -6);
+	//m_cap.set(cv::CAP_PROP_EXPOSURE, -6);
 	// 3. 降低增益ISO,减少高光噪点饱和
 	//m_cap.set(cv::CAP_PROP_GAIN, 1);
 	// 4. 提高对比度,拉开明暗层次

+ 9 - 9
zhipuzi_pos_windows/worker/CChengzhongWorker.cpp

@@ -21,10 +21,10 @@ void CChengzhongWorker::Start()
 //结束工作线程
 void CChengzhongWorker::Stop()
 {
-	m_serial.closeComm();
+	//m_serial.closeComm();
 
-	m_weight = "";
-	m_hwnd = NULL;
+	//m_weight = "";
+	//m_hwnd = NULL;
 
 	m_is_work = false;
 }
@@ -60,7 +60,7 @@ void CChengzhongWorker::HandleWork()
 	{
 		if (m_dianzicheng_lianjie == "0")
 		{
-			Sleep(200);
+			Sleep(100);
 			continue;
 		}
 
@@ -80,7 +80,7 @@ void CChengzhongWorker::HandleWork()
 			m_serial.readFromComm(a, 22, &nReaded);
 			if (nReaded <= 0)
 			{
-				Sleep(200);
+				Sleep(100);
 				continue;
 			}
 
@@ -114,7 +114,7 @@ void CChengzhongWorker::HandleWork()
 			if (nReadedTotal < 22)
 			{
 				//还是没读满22个
-				Sleep(200);
+				Sleep(100);
 				continue;
 			}
 
@@ -184,7 +184,7 @@ void CChengzhongWorker::HandleWork()
 			m_serial.readFromComm(a, 16, &nReaded);
 			if (nReaded <= 0)
 			{
-				Sleep(200);
+				Sleep(100);
 				continue;
 			}
 
@@ -218,7 +218,7 @@ void CChengzhongWorker::HandleWork()
 			if (nReadedTotal < 16)
 			{
 				//还是没读满16个
-				Sleep(200);
+				Sleep(100);
 				continue;
 			}
 
@@ -258,7 +258,7 @@ void CChengzhongWorker::HandleWork()
 			//暂时不支持的其他型号
 			this->UpdateShow("0.000");
 
-			Sleep(200);
+			Sleep(100);
 
 			continue;
 		}

+ 1 - 1
zhipuzi_pos_windows/worker/CCommonWorker.cpp

@@ -46,7 +46,7 @@ void CCommonWorker::HandleConfirm()
 		{
 			m_confirm_mutex.unlock();
 
-			CSystem::my_sleep(1);
+			Sleep(100);
 			continue;
 		}
 

+ 2 - 2
zhipuzi_pos_windows/worker/CDiandanAIShibieWorker.cpp

@@ -171,14 +171,14 @@ void CDiandanAIShibieWorker::HandleDiandanAIShibie()
 	{
 		if (m_is_ai_shibie == false)
 		{
-			Sleep(1000);
+			Sleep(100);
 			continue;
 		}
 
 		//暂时不做循环识别模式
 		//this->DoAIShibie();
 
-		Sleep(200);
+		Sleep(100);
 	}
 
 	//走到这里说明线程要退出了,做一些清理工作

+ 3 - 3
zhipuzi_pos_windows/worker/CPosPrinterWorker.cpp

@@ -74,7 +74,7 @@ void CPosPrinterWorker::HandleShouyinPrinter()
 		{
 			m_shouyin_printer_mutex.unlock();
 
-			CSystem::my_sleep(1);
+			Sleep(100);
 			continue;
 		}
 
@@ -100,7 +100,7 @@ void CPosPrinterWorker::HandleBiaoqianPrinter()
 		{
 			m_biaoqian_printer_mutex.unlock();
 
-			CSystem::my_sleep(1);
+			Sleep(100);
 			continue;
 		}
 
@@ -126,7 +126,7 @@ void CPosPrinterWorker::HandleChufangPrinter()
 		{
 			m_chufang_printer_mutex.unlock();
 
-			CSystem::my_sleep(1);
+			Sleep(100);
 			continue;
 		}