zhaoyadi před 2 roky
rodič
revize
351d3e5e76

binární
.vs/OpenCVDetect/v17/.suo


binární
.vs/OpenCVDetect/v17/Browse.VC.db


+ 57 - 8
OpenCVDetect/OpenCVDetect.cpp

@@ -3,7 +3,10 @@
 #include <iostream>
 #include <fstream>
 #include <vector>
+#include <map>
 #include <filesystem>
+#include <opencv2/imgproc/imgproc.hpp>
+#include <opencv2/highgui/highgui.hpp>
 
 using namespace cv;
 using namespace cv::xfeatures2d;
@@ -14,6 +17,8 @@ typedef void process(const path& input, const path& output);
 
 const auto detector1 = SIFT::create();
 const auto detector2 = SURF::create();
+
+const auto matcher = FlannBasedMatcher::create();
 /// <summary>
 /// 提取图片特征描述符
 /// </summary>
@@ -114,6 +119,7 @@ void process_image3(const path& image, const path& output) {
 	//		cout << element << endl;
 	//	}
 	//}
+
 	cout << "after:  " << descriptor_cat.type() << " - " << descriptor_cat.channels() << endl;
 
 	FileStorage file_storage(output.string(), FileStorage::WRITE);
@@ -191,18 +197,61 @@ void process_mat(string input_dir, string output_dir, const string& suffix, proc
 	deep_copy(input_dir_path, output_dir_path, suffix, process);
 }
 
+void test(string img, string temp) {
+	Mat mat = imread(img);
+
+	vector<KeyPoint> keypoints_cat;
+	Mat descriptor_cat;
+	detector1->detectAndCompute(mat, Mat(), keypoints_cat, descriptor_cat);
+
+	map<string, Mat> temps;
+	for (auto& it : directory_iterator(path(temp))) {
+		Mat t = imread(it.path().string());
+		vector<KeyPoint> kp;
+		Mat des;
+		detector1->detectAndCompute(t, Mat(), kp, des);
+		temps.emplace(it.path().string().c_str(), des);
+	}
+
+	for (auto it2 = temps.begin(); it2 != temps.end(); ++it2) {
+		auto name = it2->first;
+		auto value = it2->second;
+
+		vector<vector<DMatch>> result;
+		matcher->knnMatch(value, descriptor_cat, result, 2);
+
+		int count = 0;
+
+		for (auto match : result) {
+			if (match.at(0).distance < 0.7f * match.at(1).distance) {
+				count++;
+			}
+		}
+
+		cout << name << " ----- " << count << endl;
+	}
+}
+
 int main(int argc, char** argv) {
-	string input_dir = "D:\\Work\\Cards";
+	//string img = "C:\\Users\\zhaoyadi\\Desktop\\undefined.png";
+	//string temp = "D:\\process\\origin\\A-1-3";
+	//test(img, temp);
+
+	string input_dir = "D:\\process\\origin";
 	//string output_dir = "D:\\Work\\Outputs";
-	string output_dir1 = "D:\\Work\\SIFT";
-	string output_dir2 = "D:\\Work\\SURF";
-	string output_dir3 = "D:\\Work\\SIFT-XML";
-	string output_dir4 = "D:\\Work\\SURF-XML";
+	string output_dir1 = "D:\\process\\SIFT";
+	//string output_dir2 = "D:\\process\\SURF";
+	//string output_dir3 = "D:\\process\\SIFT-XML";
+	//string output_dir4 = "D:\\process\\SURF-XML";
+	//string output_dir5 = "D:\\process\\SIFT-JSON";
+	//string output_dir6 = "D:\\process\\SURF-JSON";
 
 	process_mat(input_dir, output_dir1, "png", process_image1);
-	process_mat(input_dir, output_dir2, "png", process_image2);
-	process_mat(input_dir, output_dir3, "xml", process_image3);
-	process_mat(input_dir, output_dir4, "xml", process_image4);
+	//process_mat(input_dir, output_dir2, "png", process_image2);
+	//process_mat(input_dir, output_dir3, "xml", process_image3);
+	//process_mat(input_dir, output_dir4, "xml", process_image4);
+	//process_mat(input_dir, output_dir5, "json", process_image3);
+	//process_mat(input_dir, output_dir6, "json", process_image4);
 
 	return 0;
 }

+ 2 - 2
OpenCVDetect/OpenCVDetect.vcxproj

@@ -71,8 +71,8 @@
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IncludePath>D:\Code\build\install\include\opencv2;D:\Code\build\install\include;$(IncludePath)</IncludePath>
-    <LibraryPath>D:\Code\build\install\x64\vc17\lib;$(LibraryPath)</LibraryPath>
+    <IncludePath>D:\demo\.cmake\opencv-4.6.0\opencv-4.6.0-build\install\include\opencv2;D:\demo\.cmake\opencv-4.6.0\opencv-4.6.0-build\install\include;$(IncludePath)</IncludePath>
+    <LibraryPath>D:\demo\.cmake\opencv-4.6.0\opencv-4.6.0-build\install\x64\vc17\lib;$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>

+ 1 - 1
OpenCVDetect/x64/Debug/OpenCVDetect.exe.recipe

@@ -2,7 +2,7 @@
 <Project>
   <ProjectOutputs>
     <ProjectOutput>
-      <FullPath>D:\Project\CppPorjects\OpenCVDetect\x64\Debug\OpenCVDetect.exe</FullPath>
+      <FullPath>D:\demo\.clion\luojigou_card_detect\x64\Debug\OpenCVDetect.exe</FullPath>
     </ProjectOutput>
   </ProjectOutputs>
   <ContentFiles />

binární
OpenCVDetect/x64/Debug/OpenCVDetect.ilk


+ 2 - 2
OpenCVDetect/x64/Debug/OpenCVDetect.log

@@ -1,3 +1,3 @@
   OpenCVDetect.cpp
-D:\Code\build\install\include\opencv2\xfeatures2d.hpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
-  OpenCVDetect.vcxproj -> D:\Project\CppPorjects\OpenCVDetect\x64\Debug\OpenCVDetect.exe
+D:\demo\.cmake\opencv-4.6.0\opencv-4.6.0-build\install\include\opencv2\xfeatures2d.hpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
+  OpenCVDetect.vcxproj -> D:\demo\.clion\luojigou_card_detect\x64\Debug\OpenCVDetect.exe

binární
OpenCVDetect/x64/Debug/OpenCVDetect.obj


binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/CL.command.1.tlog


binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/CL.read.1.tlog


binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/CL.write.1.tlog


+ 2 - 2
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/OpenCVDetect.lastbuildstate

@@ -1,2 +1,2 @@
-PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.34.31933:TargetPlatformVersion=10.0.22000.0:
-Debug|x64|D:\Project\CppPorjects\OpenCVDetect\|
+PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.34.31933:TargetPlatformVersion=10.0.19041.0:
+Debug|x64|D:\demo\.clion\luojigou_card_detect\|

binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/link.command.1.tlog


binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/link.read.1.tlog


binární
OpenCVDetect/x64/Debug/OpenCVDetect.tlog/link.write.1.tlog


binární
OpenCVDetect/x64/Debug/vc143.idb


binární
OpenCVDetect/x64/Debug/vc143.pdb


binární
x64/Debug/OpenCVDetect.exe


binární
x64/Debug/OpenCVDetect.pdb