Skip to content
Snippets Groups Projects
Commit cdb7e195 authored by Angel Santamaria-Navarro's avatar Angel Santamaria-Navarro
Browse files

added implementation of match. Needs debug

parent 64bf1ac2
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1476617952823822664" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1504749124108071272" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
......
...@@ -7,6 +7,7 @@ SET(headers vision_utils.h vu_base/vu_base.h cam_utils/cam_utils.h feature_detec ...@@ -7,6 +7,7 @@ SET(headers vision_utils.h vu_base/vu_base.h cam_utils/cam_utils.h feature_detec
# locate the necessary dependencies # locate the necessary dependencies
FIND_PACKAGE(Eigen3 REQUIRED) FIND_PACKAGE(Eigen3 REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED) FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(Boost REQUIRED)
if (OpenCV_FOUND) if (OpenCV_FOUND)
if (${OpenCV_VERSION_MAJOR} GREATER 2) if (${OpenCV_VERSION_MAJOR} GREATER 2)
...@@ -23,13 +24,13 @@ endif(OpenCV_FOUND) ...@@ -23,13 +24,13 @@ endif(OpenCV_FOUND)
# add the necessary include directories # add the necessary include directories
INCLUDE_DIRECTORIES(. ${EIGEN3_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(. ${EIGEN3_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
# create the shared library # create the shared library
ADD_LIBRARY(vision_utils SHARED ${sources}) ADD_LIBRARY(vision_utils SHARED ${sources})
# link necessary libraries # link necessary libraries
TARGET_LINK_LIBRARIES(vision_utils ${OpenCV_LIBS}) TARGET_LINK_LIBRARIES(vision_utils ${OpenCV_LIBS} ${Boost_LIBRARIES})
# install # install
INSTALL(TARGETS vision_utils INSTALL(TARGETS vision_utils
......
...@@ -50,14 +50,14 @@ int main(int argc, char *argv[]) ...@@ -50,14 +50,14 @@ int main(int argc, char *argv[])
if (!detector.isLine()) if (!detector.isLine())
{ {
CFeature_Detector::KeyPointVector keypoints; KeyPointVector keypoints;
keypoints = detector.detectKeyPoints(frame); keypoints = detector.detectKeyPoints(frame);
// Show frame with features // Show frame with features
detector.drawKeyFeatures(frame, keypoints); detector.drawKeyFeatures(frame, keypoints);
} }
else else
{ {
CFeature_Detector::KeyLineVector keypoints; KeyLineVector keypoints;
keypoints = detector.detectKeyLines(frame); keypoints = detector.detectKeyLines(frame);
// Show frame with features // Show frame with features
detector.drawKeyFeatures(frame, keypoints); detector.drawKeyFeatures(frame, keypoints);
......
...@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) ...@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
cv::imshow("Original image", frame); cv::imshow("Original image", frame);
// Detector // Detector
CFeature_Detector::KeyPointVector keypoints; KeyPointVector keypoints;
keypoints = detector.detectKeyPoints(frame); keypoints = detector.detectKeyPoints(frame);
// Descriptor // Descriptor
......
...@@ -44,6 +44,7 @@ int main(int argc, char *argv[]) ...@@ -44,6 +44,7 @@ int main(int argc, char *argv[])
CFeature_Matcher matcher; CFeature_Matcher matcher;
CMatcher_Params matcher_params; // TODO: Fill parameters CMatcher_Params matcher_params; // TODO: Fill parameters
CMatcher_Params matcher_search_params; // TODO: Fill parameters
std::vector<std::string> matchers_list; std::vector<std::string> matchers_list;
matchers_list = matcher.list(); matchers_list = matcher.list();
...@@ -56,7 +57,21 @@ int main(int argc, char *argv[]) ...@@ -56,7 +57,21 @@ int main(int argc, char *argv[])
std::cin >> match_type; std::cin >> match_type;
matcher.set(matchers_list[match_type],matcher_params); matcher.set(matchers_list[match_type],matcher_params);
std::cout << std::endl << "Testing: " << detectors_list[feat_type] << " + " << descriptor_list[desc_type] << " + " << matchers_list[match_type] << " (DETECTOR + DESCRIPTOR + MATCHER)" << std::endl; std::vector<std::string> matchers_out_list;
matchers_out_list = matcher.listSearchTypes();
for (unsigned int ii=0; ii<matchers_out_list.size(); ii++)
std::cout << "[" << ii << "]: " << matchers_out_list[ii] << std::endl;
std::cout << std::endl << "Which MATCHER SEARCH do you want to test?: ";
int match_search_type;
std::cin >> match_search_type;
matcher.setSearchType(matchers_out_list[match_search_type],matcher_search_params);
std::cout << std::endl << "Testing: " << detectors_list[feat_type] << " + " << descriptor_list[desc_type] << " + " << matchers_list[match_type] << " + " << matchers_out_list[match_search_type] << " (DETECTOR + DESCRIPTOR + MATCHER + MATCHER SEARCH)" << std::endl;
// matcher objects
KeyPointVector keypoints_old;
// Open camera // Open camera
cv::VideoCapture cam; cv::VideoCapture cam;
...@@ -81,19 +96,20 @@ int main(int argc, char *argv[]) ...@@ -81,19 +96,20 @@ int main(int argc, char *argv[])
cv::imshow("Original image", frame); cv::imshow("Original image", frame);
// Detector // Detector
CFeature_Detector::KeyPointVector keypoints; KeyPointVector keypoints;
keypoints = detector.detectKeyPoints(frame); keypoints = detector.detectKeyPoints(frame);
// Descriptor // Descriptor
cv::Mat descriptors; cv::Mat descriptors;
descriptors = descriptor.getDescriptor(frame,keypoints); descriptors = descriptor.getDescriptor(frame,keypoints);
// TODO: Implement matcher // // Matcher
// if (nframe > 0) // if (nframe > 0)
// { // {
// cv::Mat matchs; // std::vector<cv::DMatch> matches;
// matchs = matcher.match(); // matcher.match(keypoints,keypoints_old,matches);
// } // }
// keypoints_old = keypoints;
// Show frame with features // Show frame with features
detector.drawKeyFeatures(frame, keypoints); detector.drawKeyFeatures(frame, keypoints);
......
...@@ -104,7 +104,7 @@ bool CFeature_Descriptor::init(const std::string& _type, const CDescriptor_Param ...@@ -104,7 +104,7 @@ bool CFeature_Descriptor::init(const std::string& _type, const CDescriptor_Param
return true; return true;
} }
cv::Mat CFeature_Descriptor::getDescriptor(const cv::Mat& _image, CFeature_Descriptor::KeyPointVector& _kpts) cv::Mat CFeature_Descriptor::getDescriptor(const cv::Mat& _image, KeyPointVector& _kpts)
{ {
if (!is_init_) if (!is_init_)
std::cerr << "[CFeature_Descriptor::getDescriptor]: Descriptor non initialized." << std::endl; std::cerr << "[CFeature_Descriptor::getDescriptor]: Descriptor non initialized." << std::endl;
......
#ifndef _FEATURE_DESCRIPTOR_H #ifndef _FEATURE_DESCRIPTOR_H
#define _FEATURE_DESCRIPTOR_H #define _FEATURE_DESCRIPTOR_H
#include <time.h>
// Own
#include <vu_base/vu_base.h> #include <vu_base/vu_base.h>
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
typedef cv::Ptr<cv::DescriptorExtractor> FeatureDescriptorPtr; typedef cv::Ptr<cv::DescriptorExtractor> FeatureDescriptorPtr;
/** /**
...@@ -35,8 +22,6 @@ class CFeature_Descriptor: public CVu_Base <CDescriptor_Params>{ ...@@ -35,8 +22,6 @@ class CFeature_Descriptor: public CVu_Base <CDescriptor_Params>{
public: public:
typedef std::vector<cv::KeyPoint> KeyPointVector;
CFeature_Descriptor(const std::string& _type, const CDescriptor_Params& _params); CFeature_Descriptor(const std::string& _type, const CDescriptor_Params& _params);
CFeature_Descriptor(void); CFeature_Descriptor(void);
...@@ -46,7 +31,7 @@ public: ...@@ -46,7 +31,7 @@ public:
* \brief Get descriptors * \brief Get descriptors
*/ */
cv::Mat getDescriptor(const cv::Mat& _image, cv::Mat getDescriptor(const cv::Mat& _image,
CFeature_Descriptor::KeyPointVector& _kpts); KeyPointVector& _kpts);
private: private:
......
...@@ -136,13 +136,13 @@ int CFeature_Detector::getKeyPointsLimit(void) ...@@ -136,13 +136,13 @@ int CFeature_Detector::getKeyPointsLimit(void)
return keypoints_limit_; return keypoints_limit_;
} }
CFeature_Detector::KeyPointVector CFeature_Detector::detectKeyPoints(const cv::Mat& _image) KeyPointVector CFeature_Detector::detectKeyPoints(const cv::Mat& _image)
{ {
cv::Mat mask = cv::Mat::ones(_image.size(), CV_8U); cv::Mat mask = cv::Mat::ones(_image.size(), CV_8U);
return detectKeyPoints(_image, mask); return detectKeyPoints(_image, mask);
} }
CFeature_Detector::KeyPointVector CFeature_Detector::detectKeyPoints(const cv::Mat& _image, const cv::Mat& _mask) KeyPointVector CFeature_Detector::detectKeyPoints(const cv::Mat& _image, const cv::Mat& _mask)
{ {
if (!is_init_) if (!is_init_)
std::cerr << "[CFeature_Detector::detectKeyPoints]: Detector non initialized." << std::endl; std::cerr << "[CFeature_Detector::detectKeyPoints]: Detector non initialized." << std::endl;
...@@ -162,13 +162,13 @@ CFeature_Detector::KeyPointVector CFeature_Detector::detectKeyPoints(const cv::M ...@@ -162,13 +162,13 @@ CFeature_Detector::KeyPointVector CFeature_Detector::detectKeyPoints(const cv::M
return kpts; return kpts;
} }
CFeature_Detector::KeyLineVector CFeature_Detector::detectKeyLines(const cv::Mat& _image) KeyLineVector CFeature_Detector::detectKeyLines(const cv::Mat& _image)
{ {
cv::Mat mask = cv::Mat::ones(_image.size(), CV_8U); cv::Mat mask = cv::Mat::ones(_image.size(), CV_8U);
return detectKeyLines(_image, mask); return detectKeyLines(_image, mask);
} }
CFeature_Detector::KeyLineVector CFeature_Detector::detectKeyLines(const cv::Mat& _image, const cv::Mat& _mask) KeyLineVector CFeature_Detector::detectKeyLines(const cv::Mat& _image, const cv::Mat& _mask)
{ {
if (!is_init_) if (!is_init_)
std::cerr << "[CFeature_Detector::detectKeyLines]: Detector non initialized." << std::endl; std::cerr << "[CFeature_Detector::detectKeyLines]: Detector non initialized." << std::endl;
...@@ -198,24 +198,4 @@ bool CFeature_Detector::setLimitKeypts(unsigned int _nFeatures) ...@@ -198,24 +198,4 @@ bool CFeature_Detector::setLimitKeypts(unsigned int _nFeatures)
return false; return false;
} }
cv::Mat CFeature_Detector::drawKeyFeatures(const cv::Mat& _image, const KeyPointVector& _kp_vec)
{
cv::Mat img_out(_image);
for (unsigned int ii = 0; ii < _kp_vec.size(); ++ii)
cv::circle(img_out, _kp_vec[ii].pt, 5, cv::Scalar(128, 128, 255), -1);
return img_out;
}
cv::Mat CFeature_Detector::drawKeyFeatures(const cv::Mat& _image, const KeyLineVector& _kl_vec)
{
cv::Mat img_out(_image);
for (unsigned int ii = 0; ii < _kl_vec.size(); ++ii)
cv::line(img_out, _kl_vec[ii].getStartPoint(), _kl_vec[ii].getEndPoint(), cv::Scalar(128, 128, 255), 3);
return img_out;
}
#ifndef _FEATURE_DETECTOR_H #ifndef _FEATURE_DETECTOR_H
#define _FEATURE_DETECTOR_H #define _FEATURE_DETECTOR_H
#include <time.h>
// Own
#include <vu_base/vu_base.h> #include <vu_base/vu_base.h>
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
#define SCALE_FACTOR_LINE_DETECTOR 2 #define SCALE_FACTOR_LINE_DETECTOR 2
#define NUM_OCTAVE_LINE_DETECTOR 1 #define NUM_OCTAVE_LINE_DETECTOR 1
...@@ -41,9 +29,6 @@ public: ...@@ -41,9 +29,6 @@ public:
class CFeature_Detector: public CVu_Base <CDetector_Params> { class CFeature_Detector: public CVu_Base <CDetector_Params> {
public: public:
typedef std::vector<cv::KeyPoint> KeyPointVector;
typedef std::vector<cv::line_descriptor::KeyLine> KeyLineVector;
/** /**
* \brief Constructor * \brief Constructor
*/ */
...@@ -83,14 +68,6 @@ public: ...@@ -83,14 +68,6 @@ public:
KeyLineVector detectKeyLines(const cv::Mat& _image); KeyLineVector detectKeyLines(const cv::Mat& _image);
KeyLineVector detectKeyLines(const cv::Mat& _image, const cv::Mat& _mask); KeyLineVector detectKeyLines(const cv::Mat& _image, const cv::Mat& _mask);
/**
* \brief Draw detected features
*/
cv::Mat drawKeyFeatures(const cv::Mat& _image,
const KeyPointVector& _kp_vec);
cv::Mat drawKeyFeatures(const cv::Mat& _image,
const KeyLineVector& _kl_vec);
private: private:
// Flags // Flags
......
#include "feature_matcher.h" #include "feature_matcher.h"
CFeature_Matcher::CFeature_Matcher(const std::string& _type, const CMatcher_Params& _params) CFeature_Matcher::CFeature_Matcher(const std::string& _type, const std::string& _match_out_type, const CMatcher_Params& _params)
{ {
setAllTypes(); setAllTypes();
...@@ -28,6 +28,35 @@ void CFeature_Matcher::setAllTypes(void) ...@@ -28,6 +28,35 @@ void CFeature_Matcher::setAllTypes(void)
std::vector<std::string> types; std::vector<std::string> types;
types += "FlannBased", "BruteForce", "BruteForce-L1", "BruteForce-Hamming", "BruteForce-Hamming(2)"; types += "FlannBased", "BruteForce", "BruteForce-L1", "BruteForce-Hamming", "BruteForce-Hamming(2)";
types_.set(types); types_.set(types);
// Define all match output variants
std::vector<std::string> out_types;
out_types += "Match", "knnMartch", "radiusMatch";
match_search_types_.set(out_types);
match_search_type_ = "Match"; // Default value
}
std::vector<std::string> CFeature_Matcher::listSearchTypes(void)
{
return match_search_types_.list();
}
bool CFeature_Matcher::setSearchType(const std::string& _type, const CMatcher_Params& _params)
{
// TODO: Set parameters for each matcher type
for (unsigned int ii = 0; ii < match_search_types_.size(); ++ii)
{
if (_type.compare(match_search_types_(ii))==0)
{
match_search_type_ = _type;
match_search_params_ = _params;
return true;
}
}
std::cerr << "[Feature Matcher]: matcher output type " << _type << " doesn't exist !" << std::endl;
return false;
} }
...@@ -80,22 +109,44 @@ bool CFeature_Matcher::init(const std::string& _type, const CMatcher_Params& _pa ...@@ -80,22 +109,44 @@ bool CFeature_Matcher::init(const std::string& _type, const CMatcher_Params& _pa
return true; return true;
} }
// TODO: Match features and process matches (e.g. https://github.com/kipr/opencv/blob/master/samples/cpp/detector_descriptor_matcher_evaluation.cpp) // TODO: Match features and process matches (e.g. https://github.com/kipr/opencv/blob/master/samples/cpp/detector_descriptor_matcher_evaluation.cpp)
void CFeature_Matcher::match(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, std::vector<cv::DMatch>& matches)
{
if (!is_init_)
std::cerr << "[CFeature_Matcher::match]: Matcher non initialized." << std::endl;
//cv::Mat CFeature_Matcher::match(const cv::Mat& _image, CFeature_Descriptor::KeyPointVector& _kpts) if (match_search_type_.compare(match_search_types_(0))==0)
//{ {
// if (!is_init_) clock_t tStart = clock();
// std::cerr << "[CFeature_Matcher::match]: Matcher non initialized." << std::endl; // TODO: use parameters related with the search type (match_search_params_)
// feature_matcher_->match( _kpts1, _kpts2, matches);
// cv::Mat descriptors; comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
// }
// clock_t tStart = clock(); else
// feature_matcher_->compute(_image, _kpts, descriptors); std::cerr << "[CFeature_Matcher::match]: The selected matcher output is different than your object." << std::endl;
// comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC; }
//
// return descriptors;
//}
// TODO: Match features and process matches (e.g. https://github.com/kipr/opencv/blob/master/samples/cpp/detector_descriptor_matcher_evaluation.cpp)
void CFeature_Matcher::match(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, std::vector< std::vector<cv::DMatch> >& matches)
{
if (!is_init_)
std::cerr << "[CFeature_Matcher::match]: Matcher non initialized." << std::endl;
if (match_search_type_.compare(match_search_types_(1))==0)// knn match
{
clock_t tStart = clock();
// TODO: use parameters related with the search type (match_search_params_)
feature_matcher_->knnMatch(_kpts1, _kpts2, matches, 2);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
else if (match_search_type_.compare(match_search_types_(2))==0) // radius match
{
clock_t tStart = clock();
// TODO: use parameters related with the search type (match_search_params_)
feature_matcher_->radiusMatch(_kpts1, _kpts2, matches, 2);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
else
std::cerr << "[CFeature_Matcher::match]: The selected matcher output is different than your object." << std::endl;
}
#ifndef _FEATURE_MATCHER_H #ifndef _FEATURE_MATCHER_H
#define _FEATURE_MATCHER_H #define _FEATURE_MATCHER_H
#include <time.h>
// own
#include "vu_base/vu_base.h" #include "vu_base/vu_base.h"
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
typedef cv::Ptr<cv::DescriptorMatcher> FeatureMatcherPtr; typedef cv::Ptr<cv::DescriptorMatcher> FeatureMatcherPtr;
/** /**
...@@ -35,21 +22,39 @@ class CFeature_Matcher: public CVu_Base<CMatcher_Params> ...@@ -35,21 +22,39 @@ class CFeature_Matcher: public CVu_Base<CMatcher_Params>
{ {
public: public:
CFeature_Matcher(const std::string& _type, const CMatcher_Params& _params); CFeature_Matcher(const std::string& _type, const std::string& _match_out_type, const CMatcher_Params& _params);
CFeature_Matcher(void); CFeature_Matcher(void);
~CFeature_Matcher(void); ~CFeature_Matcher(void);
/** /**
* \brief Match * \brief list all possible match output types (All, K nearest, in a radius search, ...)
*/
std::vector<std::string> listSearchTypes(void);
/**
* \brief Set matcher search method
*/
bool setSearchType(const std::string& _type, const CMatcher_Params& _params);
/**
* \brief Find Matches
*/
void match(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, std::vector<cv::DMatch>& matches);
/**
* \brief Find K best matches or matches in a radius (depending on selected match_search_type_)
*/ */
// cv::Mat match(const cv::Mat& _image, void match(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, std::vector< std::vector<cv::DMatch> >& matches);
// CFeature_Descriptor::KeyPointVector& _kpts);
private: private:
FeatureMatcherPtr feature_matcher_; // Feature matcher FeatureMatcherPtr feature_matcher_; // Feature matcher
CTypes match_search_types_; // Match type (match with all, knn and radius search).
CMatcher_Params match_search_params_; // Search type parameters.
std::string match_search_type_; // Match type (match with all, knn and radius search).
/** /**
* \brief Set all types * \brief Set all types
*/ */
......
...@@ -5,4 +5,3 @@ CVision_Utils::CVision_Utils() { ...@@ -5,4 +5,3 @@ CVision_Utils::CVision_Utils() {
CVision_Utils::~CVision_Utils() { CVision_Utils::~CVision_Utils() {
} }
#ifndef _VU_BASE_H #ifndef _VU_BASE_H
#define _VU_BASE_H #define _VU_BASE_H
// std
#include <functional> #include <functional>
#include <set> #include <set>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <vector> #include <vector>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <time.h>
// Boost
#include <boost/assign/std/vector.hpp> // for 'operator+=()' #include <boost/assign/std/vector.hpp> // for 'operator+=()'
using namespace boost::assign; // bring 'operator+=()' into scope using namespace boost::assign; // bring 'operator+=()' into scope
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
typedef std::vector<cv::KeyPoint> KeyPointVector;
typedef std::vector<cv::KeyPoint> KeyPointVector;
typedef std::vector<cv::line_descriptor::KeyLine> KeyLineVector;
/** /**
* \brief Class to set object types * \brief Class to set object types
*/ */
...@@ -136,6 +152,27 @@ public: ...@@ -136,6 +152,27 @@ public:
return success; return success;
}; };
cv::Mat drawKeyFeatures(const cv::Mat& _image, const KeyPointVector& _kp_vec)
{
cv::Mat img_out(_image);
for (unsigned int ii = 0; ii < _kp_vec.size(); ++ii)
cv::circle(img_out, _kp_vec[ii].pt, 5, cv::Scalar(128, 128, 255), -1);
return img_out;
}
cv::Mat drawKeyFeatures(const cv::Mat& _image, const KeyLineVector& _kl_vec)
{
cv::Mat img_out(_image);
for (unsigned int ii = 0; ii < _kl_vec.size(); ++ii)
cv::line(img_out, _kl_vec[ii].getStartPoint(), _kl_vec[ii].getEndPoint(), cv::Scalar(128, 128, 255), 3);
return img_out;
}
protected: protected:
// Flags // Flags
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment