From e055b224ed158a568619d1b45af64dfe82a85255 Mon Sep 17 00:00:00 2001
From: Joan Sola <jsola@iri.upc.edu>
Date: Fri, 4 May 2018 11:59:53 +0200
Subject: [PATCH] Add set and get match_type to matchers

---
 .cproject                                     | 44 ++++++++++++-------
 src/matchers/bruteforce/matcher_bruteforce.h  |  1 +
 .../matcher_bruteforce_hamming.h              |  1 +
 .../matcher_bruteforce_hamming_2.h            |  1 +
 .../bruteforce_l1/matcher_bruteforce_l1.h     |  1 +
 src/matchers/flannbased/matcher_flannbased.h  |  1 +
 src/matchers/matcher_base.h                   | 32 ++++++++++----
 src/vision_utils.cpp                          |  4 ++
 8 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/.cproject b/.cproject
index c75b159..bf0cc4d 100644
--- a/.cproject
+++ b/.cproject
@@ -22,9 +22,15 @@
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.530116614" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
 							<builder buildPath="${workspace_loc:/vision_utils}/build" enabledIncrementalBuild="true" id="cdt.managedbuild.builder.gnu.cross.1321287044" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
 							<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.2113617585" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
+								<option id="gnu.c.compiler.option.preprocessor.def.symbols.597556856" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="__cplusplus=201103"/>
+								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.844027082" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 							</tool>
 							<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1552607345" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
+								<option id="gnu.cpp.compiler.option.preprocessor.def.1754201403" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="__cplusplus=201103"/>
+								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2062058076" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
 							</tool>
 							<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1390296837" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
@@ -45,47 +51,53 @@
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 		</cconfiguration>
 	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="vision_utils.null.1064155195" name="vision_utils"/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Default">
+			<resource resourceType="PROJECT" workspacePath="/vision_utils"/>
+		</configuration>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
 	<storageModule moduleId="scannerConfiguration">
 		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1819918851;cdt.managedbuild.toolchain.gnu.base.1819918851.1318867162;cdt.managedbuild.tool.gnu.cpp.compiler.base.1649772065;cdt.managedbuild.tool.gnu.cpp.compiler.input.146329834">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1736073220;cdt.managedbuild.toolchain.gnu.base.1736073220.1390770886;cdt.managedbuild.tool.gnu.c.compiler.base.1459107576;cdt.managedbuild.tool.gnu.c.compiler.input.1695301683">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.c.compiler.base.1439246049;cdt.managedbuild.tool.gnu.c.compiler.input.637694474">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
 		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.727026548;cdt.managedbuild.toolchain.gnu.base.727026548.1071101131;cdt.managedbuild.tool.gnu.c.compiler.base.61708613;cdt.managedbuild.tool.gnu.c.compiler.input.166078074">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.c.compiler.base.1439246049;cdt.managedbuild.tool.gnu.c.compiler.input.637694474">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.cpp.compiler.base.1755527935;cdt.managedbuild.tool.gnu.cpp.compiler.input.1794914341">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1244102678;cdt.managedbuild.toolchain.gnu.base.1244102678.1450977940;cdt.managedbuild.tool.gnu.cpp.compiler.base.1572359948;cdt.managedbuild.tool.gnu.cpp.compiler.input.466329004">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.727026548;cdt.managedbuild.toolchain.gnu.base.727026548.1071101131;cdt.managedbuild.tool.gnu.cpp.compiler.base.433122623;cdt.managedbuild.tool.gnu.cpp.compiler.input.341288586">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.cpp.compiler.base.1755527935;cdt.managedbuild.tool.gnu.cpp.compiler.input.1794914341">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.772018425;cdt.managedbuild.toolchain.gnu.cross.base.772018425.677700058;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1552607345;cdt.managedbuild.tool.gnu.cpp.compiler.input.2062058076">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.727026548;cdt.managedbuild.toolchain.gnu.base.727026548.1071101131;cdt.managedbuild.tool.gnu.cpp.compiler.base.433122623;cdt.managedbuild.tool.gnu.cpp.compiler.input.341288586">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1819918851;cdt.managedbuild.toolchain.gnu.base.1819918851.1318867162;cdt.managedbuild.tool.gnu.c.compiler.base.593702953;cdt.managedbuild.tool.gnu.c.compiler.input.392834553">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
 		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1736073220;cdt.managedbuild.toolchain.gnu.base.1736073220.1390770886;cdt.managedbuild.tool.gnu.cpp.compiler.base.1526891046;cdt.managedbuild.tool.gnu.cpp.compiler.input.1116382079">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
-		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1819918851;cdt.managedbuild.toolchain.gnu.base.1819918851.1318867162;cdt.managedbuild.tool.gnu.c.compiler.base.593702953;cdt.managedbuild.tool.gnu.c.compiler.input.392834553">
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1736073220;cdt.managedbuild.toolchain.gnu.base.1736073220.1390770886;cdt.managedbuild.tool.gnu.c.compiler.base.1459107576;cdt.managedbuild.tool.gnu.c.compiler.input.1695301683">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+		</scannerConfigBuildInfo>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1244102678;cdt.managedbuild.toolchain.gnu.base.1244102678.1450977940;cdt.managedbuild.tool.gnu.cpp.compiler.base.1572359948;cdt.managedbuild.tool.gnu.cpp.compiler.input.466329004">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+		</scannerConfigBuildInfo>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.772018425;cdt.managedbuild.toolchain.gnu.cross.base.772018425.677700058;cdt.managedbuild.tool.gnu.cross.c.compiler.2113617585;cdt.managedbuild.tool.gnu.c.compiler.input.844027082">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
 		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1244102678;cdt.managedbuild.toolchain.gnu.base.1244102678.1450977940;cdt.managedbuild.tool.gnu.c.compiler.base.1838202852;cdt.managedbuild.tool.gnu.c.compiler.input.964584931">
 			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		</scannerConfigBuildInfo>
 	</storageModule>
-	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-		<project id="vision_utils.null.1064155195" name="vision_utils"/>
-	</storageModule>
-	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-	<storageModule moduleId="refreshScope" versionNumber="2">
-		<configuration configurationName="Default">
-			<resource resourceType="PROJECT" workspacePath="/vision_utils"/>
-		</configuration>
-	</storageModule>
-	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
 </cproject>
diff --git a/src/matchers/bruteforce/matcher_bruteforce.h b/src/matchers/bruteforce/matcher_bruteforce.h
index 24fb66d..3dccf04 100644
--- a/src/matchers/bruteforce/matcher_bruteforce.h
+++ b/src/matchers/bruteforce/matcher_bruteforce.h
@@ -54,6 +54,7 @@ inline void MatcherBRUTEFORCE::defineMatcher(const ParamsBasePtr _params)
 	MatcherParamsBasePtr params_base_ptr = std::static_pointer_cast<MatcherParamsBase>(_params);
 	params_ptr_ = std::static_pointer_cast<MatcherParamsBRUTEFORCE>(params_base_ptr);
     matcher_ = cv::DescriptorMatcher::create("BruteForce");
+    match_type_ = params_ptr_->match_type;
 }
 
 /*
diff --git a/src/matchers/bruteforce_hamming/matcher_bruteforce_hamming.h b/src/matchers/bruteforce_hamming/matcher_bruteforce_hamming.h
index 1c6ad07..d35eb2d 100644
--- a/src/matchers/bruteforce_hamming/matcher_bruteforce_hamming.h
+++ b/src/matchers/bruteforce_hamming/matcher_bruteforce_hamming.h
@@ -54,6 +54,7 @@ inline void MatcherBRUTEFORCE_HAMMING::defineMatcher(const ParamsBasePtr _params
 	MatcherParamsBasePtr params_base_ptr = std::static_pointer_cast<MatcherParamsBase>(_params);
 	params_ptr_ = std::static_pointer_cast<MatcherParamsBRUTEFORCE_HAMMING>(params_base_ptr);
     matcher_ = cv::DescriptorMatcher::create("BruteForce-Hamming");
+    match_type_ = params_ptr_->match_type;
 }
 
 /*
diff --git a/src/matchers/bruteforce_hamming_2/matcher_bruteforce_hamming_2.h b/src/matchers/bruteforce_hamming_2/matcher_bruteforce_hamming_2.h
index 9b7e00b..41cc149 100644
--- a/src/matchers/bruteforce_hamming_2/matcher_bruteforce_hamming_2.h
+++ b/src/matchers/bruteforce_hamming_2/matcher_bruteforce_hamming_2.h
@@ -54,6 +54,7 @@ inline void MatcherBRUTEFORCE_HAMMING_2::defineMatcher(const ParamsBasePtr _para
 	MatcherParamsBasePtr params_base_ptr = std::static_pointer_cast<MatcherParamsBase>(_params);
 	params_ptr_ = std::static_pointer_cast<MatcherParamsBRUTEFORCE_HAMMING_2>(params_base_ptr);
     matcher_ = cv::DescriptorMatcher::create("BruteForce-Hamming(2)");
+    match_type_ = params_ptr_->match_type;
 }
 
 /*
diff --git a/src/matchers/bruteforce_l1/matcher_bruteforce_l1.h b/src/matchers/bruteforce_l1/matcher_bruteforce_l1.h
index e2c44f2..311ba06 100644
--- a/src/matchers/bruteforce_l1/matcher_bruteforce_l1.h
+++ b/src/matchers/bruteforce_l1/matcher_bruteforce_l1.h
@@ -54,6 +54,7 @@ inline void MatcherBRUTEFORCE_L1::defineMatcher(const ParamsBasePtr _params)
 	MatcherParamsBasePtr params_base_ptr = std::static_pointer_cast<MatcherParamsBase>(_params);
 	params_ptr_ = std::static_pointer_cast<MatcherParamsBRUTEFORCE_L1>(params_base_ptr);
     matcher_ = cv::DescriptorMatcher::create("BruteForce-L1");
+    match_type_ = params_ptr_->match_type;
 }
 
 /*
diff --git a/src/matchers/flannbased/matcher_flannbased.h b/src/matchers/flannbased/matcher_flannbased.h
index d30be93..3090a5e 100644
--- a/src/matchers/flannbased/matcher_flannbased.h
+++ b/src/matchers/flannbased/matcher_flannbased.h
@@ -54,6 +54,7 @@ inline void MatcherFLANNBASED::defineMatcher(const ParamsBasePtr _params)
 	MatcherParamsBasePtr params_base_ptr = std::static_pointer_cast<MatcherParamsBase>(_params);
 	params_ptr_ = std::static_pointer_cast<MatcherParamsFLANNBASED>(params_base_ptr);
     matcher_ = cv::DescriptorMatcher::create("FlannBased");
+    match_type_ = params_ptr_->match_type;
 }
 
 /*
diff --git a/src/matchers/matcher_base.h b/src/matchers/matcher_base.h
index fbacb4d..d5710d2 100644
--- a/src/matchers/matcher_base.h
+++ b/src/matchers/matcher_base.h
@@ -66,6 +66,10 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
 
         MatcherParamsBasePtr getParams(void);
 
+        int getMatchType(void);
+
+        void setMatchType(const int& _match_type);
+
         void setParams(const MatcherParamsBasePtr _params);
 
         std::vector<Scalar> match(const cv::Mat& _desc1, const cv::Mat& _desc2, const int& desc_size_bytes, DMatchVector& matches, cv::InputArray _mask=cv::noArray());
@@ -88,6 +92,8 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
 
         std::string name_;
 
+        int match_type_;
+
         FeatureMatcherPtr matcher_;
 
         MatcherParamsBasePtr params_base_ptr_;
@@ -97,25 +103,35 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
         virtual void defineMatcher(const ParamsBasePtr _params) = 0;
 };
 
-/*
- * brief Retrieve object name
+/**
+ *\brief Retrieve object name
  */
 inline std::string MatcherBase::getName(void) { return name_; }
 
-/*
- * brief Set object name
+/**
+ *\brief Set object name
  */
 inline void MatcherBase::setName(const std::string& _name){ name_ = _name; }
 
-/*
- * brief Retrieve object parameters
+/**
+ *\brief Set matcher type
+ */
+inline void MatcherBase::setMatchType(const int& _match_type){ match_type_ = _match_type;}
+
+/**
+ *\brief Get matcher type
+ */
+inline int MatcherBase::getMatchType(void){ return match_type_;}
+
+/**
+ *\brief Retrieve object parameters
  */
 inline MatcherParamsBasePtr MatcherBase::getParams(void) { return params_base_ptr_; }
 
 inline void MatcherBase::setParams(const MatcherParamsBasePtr _params) { params_base_ptr_ = _params; }
 
-/*
- * brief Setup and get the corresponding pointer
+/**
+ *\brief Setup and get the corresponding pointer
  */
 MatcherBasePtr setupMatcher(const std::string& _type, const std::string& _unique_name, const ParamsBasePtr& _params);
 MatcherBasePtr setupMatcher(const std::string& _type, const std::string& _unique_name, const std::string& _filename_dot_yaml);
diff --git a/src/vision_utils.cpp b/src/vision_utils.cpp
index 9fcc439..6adb26b 100644
--- a/src/vision_utils.cpp
+++ b/src/vision_utils.cpp
@@ -449,6 +449,10 @@ cv::Mat buildImageProcessed(const cv::Mat& _img, const std::vector<KeyPointEnhan
         // Point
         cv::drawMarker (img, kp_e.kp.pt, kp_e.color, cv::MARKER_CROSS);
 
+        // Id
+        cv::putText(img, std::to_string(kp_e.track_id) + " (" + std::to_string(kp_e.track_length) + ")", cvPoint(kp_e.kp.pt.x+10,kp_e.kp.pt.y+5),
+            cv::FONT_HERSHEY_PLAIN, 1.0, kp_e.cov_color, 1, CV_AA);
+
         // Covariance
         Eigen::JacobiSVD<Eigen::MatrixXs> svd(kp_e.cov, Eigen::ComputeThinU | Eigen::ComputeThinV);
         Eigen::Matrix2s R = svd.matrixU();
-- 
GitLab