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

added all descriptors and deleted old folder

parent 22555681
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
#include "../descriptors/brief/descriptor_brief.h"
#include "../descriptors/daisy/descriptor_daisy.h"
#include "../descriptors/lucid/descriptor_lucid.h"
//#include "../descriptors/dense/descriptor_dense.h"
int main(void)
{
......@@ -113,8 +113,6 @@ int main(void)
des_ptr = std::static_pointer_cast<DescriptorDAISY>(des_ptr);
else if (des_name.compare("LUCID") == 0)
des_ptr = std::static_pointer_cast<DescriptorLUCID>(des_ptr);
// else if (des_name.compare("DENSE") == 0)
// des_ptr = std::static_pointer_cast<DescriptorDENSE>(des_ptr);
std::cout << std::endl << "... Testing " << det_ptr->getName() << " with " << des_ptr->getName() << " ..." << std::endl;
......
#include "feature_descriptor.h"
FeatureDescriptor::FeatureDescriptor(const std::string& _type, const DescriptorParams& _params)
{
setAllTypes();
is_init_ = init(_type, _params);
if (!is_init_)
{
std::cerr
<< "[Feature Descriptor]: Something went wrong during initialization! Feature Descriptor not initialized."
<< std::endl;
}
}
FeatureDescriptor::FeatureDescriptor()
{
setAllTypes();
}
FeatureDescriptor::~FeatureDescriptor() {
}
void FeatureDescriptor::setAllTypes(void)
{
// Define all types
std::vector<std::string> types;
types += "ORB", "SIFT", "SURF", "KAZE", "AKAZE", "BRISK", "LATCH", "FREAK", "BRIEF", "DAISY", "LUCID";
types_.set(types);
type_ = "ORB"; // Default value
}
bool FeatureDescriptor::init(const std::string& _type, const DescriptorParams& _params)
{
if (is_init_)
{
std::cerr << "[FeatureDescriptor]: Descriptor already initialized." << std::endl;
return false;
}
// TODO: Set parameters for each detector type
if (_type.compare(types_(0))==0)
{
feature_descriptor_ = cv::ORB::create();
type_ = types_(0);
}
else if (_type.compare(types_(1))==0)
{
feature_descriptor_ = cv::xfeatures2d::SIFT::create();
type_ = types_(1);
}
else if (_type.compare(types_(2))==0)
{
feature_descriptor_ = cv::xfeatures2d::SURF::create();
type_ = types_(2);
}
else if (_type.compare(types_(3))==0)
{
feature_descriptor_ = cv::KAZE::create();
type_ = types_(3);
}
else if (_type.compare(types_(4))==0)
{
feature_descriptor_ = cv::AKAZE::create();
type_ = types_(4);
}
else if (_type.compare(types_(5))==0)
{
feature_descriptor_ = cv::BRISK::create();
type_ = types_(0);
}
else if (_type.compare(types_(6))==0)
{
feature_descriptor_ = cv::xfeatures2d::LATCH::create();
type_ = types_(6);
}
else if (_type.compare(types_(7))==0)
{
feature_descriptor_ = cv::xfeatures2d::FREAK::create();
type_ = types_(7);
}
else if (_type.compare(types_(8))==0)
{
feature_descriptor_ = cv::xfeatures2d::BriefDescriptorExtractor::create();
type_ = types_(8);
}
else if (_type.compare(types_(9))==0)
{
feature_descriptor_ = cv::xfeatures2d::DAISY::create();
type_ = types_(9);
}
else if (_type.compare(types_(10))==0)
{
feature_descriptor_ = cv::xfeatures2d::LUCID::create(1,2);
type_ = types_(10);
}
else
{
std::cerr << "[Feature Descriptor]: descriptor type " << _type << " doesn't exist !" << std::endl;
return false;
}
is_init_ = true;
return true;
}
cv::Mat FeatureDescriptor::getDescriptor(const cv::Mat& _image, KeyPointVector& _kpts)
{
if (!is_init_)
std::cerr << "[FeatureDescriptor::getDescriptor]: Descriptor non initialized." << std::endl;
cv::Mat descriptors;
clock_t tStart = clock();
if (!_kpts.empty())
feature_descriptor_->compute(_image, _kpts, descriptors);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
return descriptors;
}
#ifndef _FEATURE_DESCRIPTOR_H
#define _FEATURE_DESCRIPTOR_H
#include "../vision_utils.h"
typedef cv::Ptr<cv::DescriptorExtractor> FeatureDescriptorPtr;
/**
* \brief Feature descriptor parameters class
*/
class DescriptorParams: public ParamsBase {
public:
DescriptorParams(void) {
}
;
~DescriptorParams(void) {
}
;
};
class FeatureDescriptor: public VUBase {
public:
FeatureDescriptor(const std::string& _type, const DescriptorParams& _params);
FeatureDescriptor(void);
~FeatureDescriptor(void);
/**
* \brief Get descriptors
*/
cv::Mat getDescriptor(const cv::Mat& _image,
KeyPointVector& _kpts);
private:
FeatureDescriptorPtr feature_descriptor_; // Feature point descriptor
/**
* \brief Set all types
*/
void setAllTypes(void);
/**
* \brief Initialize descriptor
*/
bool init(const std::string &_type, const DescriptorParams &_params);
};
#endif
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