张洋 8 stundas atpakaļ
vecāks
revīzija
2e5ef97177

BIN
bin/Win32/Release/zhipuzi_pos_windows/3.jpg


BIN
bin/Win32/Release/zhipuzi_pos_windows/ai/yolo26n-cls-fruit.onnx


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


BIN
res/ai/yolo26n-cls-fruit.onnx


BIN
res/images/huangguyu/1.webp


BIN
res/images/huangguyu/2.jpg


BIN
res/images/huangguyu/3.webp


BIN
res/images/huangguyu/4.webp


BIN
res/images/niurou/1.jpg


BIN
res/images/niurou/2.webp


BIN
res/images/niurou/3.webp


BIN
res/images/niurou/4.jpg


BIN
res/images/niurou/5.jpg


+ 1 - 1
zhipuzi_pos_windows/ai/ImageProcessor.cpp

@@ -30,7 +30,7 @@ std::vector<std::string> ImageProcessor::getImagesInDirectory(const std::string
 
 bool ImageProcessor::isImageFile(const std::string & filename)
 {
-	std::vector<std::string> extensions = { ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif" };
+	std::vector<std::string> extensions = { ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".webp"};
 	std::string lowerFilename = filename;
 	std::transform(lowerFilename.begin(), lowerFilename.end(), lowerFilename.begin(), ::tolower);
 

+ 3 - 16
zhipuzi_pos_windows/ai/YoloFeatureExtractor.cpp

@@ -10,7 +10,7 @@
 #include "../tool/debuglog.h"
 
 YoloFeatureExtractor::YoloFeatureExtractor(const std::string & modelPath, const std::string & classesPath)
-	: inputWidth(800), inputHeight(800)
+	: inputWidth(224), inputHeight(224)
 {
 	net = cv::dnn::readNetFromONNX(modelPath);
 	loadClassNames(classesPath);
@@ -85,21 +85,8 @@ std::vector<float> YoloFeatureExtractor::extractFeatures(const std::string & ima
 		std::vector<cv::String> layerNames = net.getLayerNames();
 		std::vector<cv::String> outputNames;
 
-		// 选择合适的特征层(使用倒数第二个卷积层作为特征提取层)
-		if (layerNames.size() >= 8)
-		{
-			// 通常倒数第8层左右是较好的特征层
-			outputNames.push_back(layerNames[layerNames.size() - 6]);
-		}
-		else if (layerNames.size() >= 2)
-		{
-			outputNames.push_back(layerNames[layerNames.size() - 2]);
-		}
-		
-		else
-		{
-			outputNames.push_back(layerNames.back());
-		}
+		// 选择GAP层(对于yolo2026,通常是倒数第6层)的输出作为特征向量
+		outputNames.push_back(layerNames[layerNames.size() - 6]);
 
 		std::vector<cv::Mat> outputs;
 		net.forward(outputs, outputNames);

+ 1 - 1
zhipuzi_pos_windows/ai/test.cpp

@@ -31,7 +31,7 @@ int AITest()
 		//用于测试的图片目录
 		std::string galleryDir = (mainDir.parent_path().parent_path().parent_path().parent_path() /"res"/"images").string();       // 图库目录路径
 
-		std::string modelPath = sMainDir + "/ai/best.onnx";           // YOLO2026模型路径
+		std::string modelPath = sMainDir + "/ai/yolo26n-cls.onnx";           // YOLO2026模型路径
 		std::string classesPath = sMainDir + "/ai/cls.names";             // 类别文件路径
 		std::string searchImagePath = sMainDir + "/3.jpg"; // 搜索图片路径