Просмотр исходного кода

都能运行,现在就是排查性能的问题

张洋 1 месяц назад
Родитель
Сommit
fc7a42d7a0

BIN
bin/Win32/Debug/zhipuzi_pos_windows/db/image_features.db


BIN
bin/Win32/Release/zhipuzi_pos_windows/DuiLib.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/ai/best.onnx


+ 2 - 0
bin/Win32/Release/zhipuzi_pos_windows/ai/cls.names

@@ -0,0 +1,2 @@
+car
+bus

BIN
bin/Win32/Release/zhipuzi_pos_windows/libcrypto-3.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/libcurl.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/libssl-3.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/log4cplusU.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/opencv_world4120.dll


BIN
dll/release/opencv_world4120.dll


BIN
lib/release/opencv_world4120.lib


BIN
res/image_features.db


+ 1 - 1
zhipuzi_pos_windows/ai/ImageProcessor.cpp

@@ -1,4 +1,4 @@
-
+
 #include "ImageProcessor.h"
 #include <filesystem>
 #include <algorithm>

+ 1 - 1
zhipuzi_pos_windows/ai/ImageProcessor.h

@@ -1,4 +1,4 @@
-
+
 #pragma once
 #include <string>
 #include <vector>

+ 1 - 1
zhipuzi_pos_windows/ai/SQLiteVecManager.h

@@ -1,4 +1,4 @@
-
+
 #pragma once
 #include <vector>
 #include <string>

+ 6 - 2
zhipuzi_pos_windows/ai/YoloFeatureExtractor.cpp

@@ -1,9 +1,12 @@
-
+#include "../pch/pch.h"
+
 #include "YoloFeatureExtractor.h"
 #include <fstream>
 #include <algorithm>
 #include <iostream>
 
+#include "../tool/debuglog.h"
+
 YoloFeatureExtractor::YoloFeatureExtractor(const std::string & modelPath, const std::string & classesPath)
 	: inputWidth(640), inputHeight(640)
 {
@@ -52,7 +55,8 @@ std::vector<float> YoloFeatureExtractor::extractFeatures(const std::string & ima
 	auto end_time = std::chrono::high_resolution_clock::now();
 	auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
 
-	int time = duration.count();
+	std::wstring msg = L"特征提取完成,耗时: " + std::to_wstring(duration.count()) + L" 毫秒";
+	DEBUG_LOG(msg.c_str());
 
 	return features;
 }

+ 1 - 1
zhipuzi_pos_windows/ai/YoloFeatureExtractor.h

@@ -1,4 +1,4 @@
-
+
 #pragma once
 #include <opencv2/opencv.hpp>
 #include <opencv2/dnn.hpp>

+ 16 - 1
zhipuzi_pos_windows/ai/test.cpp

@@ -6,8 +6,19 @@
 #include "ImageProcessor.h"
 #include "SQLiteVecManager.h"
 
+#include "../tool/CSetting.h"
+#include "../tool/debuglog.h"
+
+#include <opencv2/opencv.hpp>
+
+#include <filesystem>
+
+
+
 int AITest()
 {
+	
+
 	try
 	{
 		// 设置路径(可根据实际情况修改)
@@ -15,7 +26,11 @@ int AITest()
 		std::string classesPath = "E:\\code\\zhipuzi\\zhipuzi_pos_windows\\res\\ai\\cls.names";             // 类别文件路径
 		std::string galleryDir = "E:\\code\\zhipuzi\\zhipuzi_pos_windows\\res\\images";       // 图库目录路径
 		std::string searchImagePath = "E:\\code\\zhipuzi\\zhipuzi_pos_windows\\res\\3.jpg"; // 搜索图片路径
-		std::string databasePath = "E:\\code\\zhipuzi\\zhipuzi_pos_windows\\res\\image_features.db";     // SQLite数据库路径
+
+		std::wstring folderPath = CSystem::GetProgramDir() + L"\\db\\image_features.db";
+		std::string databasePath = CLewaimaiString::UnicodeToUTF8(folderPath);
+
+		std::filesystem::remove(folderPath);
 
 		std::cout << "=== YOLO2026图像检索系统 (SQLite-Vec版本) ===" << std::endl;
 		std::cout << "模型路径: " << modelPath << std::endl;

+ 3 - 3
zhipuzi_pos_windows/helper/CBitmapHelper.h

@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
 
 #include "../pch/pch.h"
 
@@ -24,10 +24,10 @@ public:
 
 	void UnlockBitmap(Gdiplus::Bitmap *bmp, BitmapData *data);
 
-	//ת³É»Ò¶Èͼ
+	//转��度图
 	void Gray(BitmapData *data);
 
-	//ת³É¶þֵͼ
+	//转�二值图
 	void GrayAnd2Values(BitmapData *data);
 
 	void Image2Values();

+ 26 - 0
zhipuzi_pos_windows/tool/debuglog.h

@@ -0,0 +1,26 @@
+#pragma once
+#include <windows.h>
+#include <sstream>
+#include <cstdio>
+
+#define DEBUG_LOG_BUFFER_SIZE 1024
+
+#define DEBUG_LOG(msg) do { \
+    std::wostringstream __oss; \
+    __oss << L"[" << __func__ << L"]@" << __FILE__ << L":" << __LINE__ << L": " << msg << L"\n"; \
+    OutputDebugString(__oss.str().c_str()); \
+} while(0)
+
+#define DEBUG_LOG_VAR(msg, val) do { \
+    std::wostringstream __oss; \
+    __oss << L"[" << __func__ << L"]@" << __FILE__ << L":" << __LINE__ << L": " << msg << L": " << val << L"\n"; \
+    OutputDebugString(__oss.str().c_str()); \
+} while(0)
+
+#define DEBUG_LOG_FMT(format, ...) do { \
+    wchar __logbuf[DEBUG_LOG_BUFFER_SIZE]; \
+    std::swprintf(__logbuf, DEBUG_LOG_BUFFER_SIZE, format, ##__VA_ARGS__); \
+    wchar __fullmsg[DEBUG_LOG_BUFFER_SIZE + 128]; \
+    std::swprintf(__fullmsg, sizeof(__fullmsg), L"[%s]@%s:%d: %s\n", __func__, __FILE__, __LINE__, __logbuf); \
+    OutputDebugString(__fullmsg); \
+} while(0)

+ 3 - 3
zhipuzi_pos_windows/zhipuzi_pos_windows.cpp

@@ -22,16 +22,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
 		return -1;
 	}
 
-	AITest();
-
 
 	//初始化日志,这个一定要放在这里,才不会被析构掉
 	CLewaimaiLog log;
 	log.Init();
 
+	AITest();
+
 	//初始化所有配置,启动所有异步worker
 	CAppEnv app;
-	app.Start();	
+	app.Start();
 
     //开始展示窗口
     CPaintManagerUI::SetInstance(hInstance);

Разница между файлами не показана из-за своего большого размера
+ 4 - 1
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj


+ 3 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -384,6 +384,9 @@
     <ClInclude Include="ai\YoloFeatureExtractor.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="tool\debuglog.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">