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

added brief descriptor

parent b1dae5e4
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,8 @@ SET(sources
descriptors/latch/descriptor_latch_load_yaml.cpp
descriptors/freak/descriptor_freak.cpp
descriptors/freak/descriptor_freak_load_yaml.cpp
descriptors/brief/descriptor_brief.cpp
descriptors/brief/descriptor_brief_load_yaml.cpp
matchers/matcher_base.cpp )
# application header files
......@@ -78,7 +80,8 @@ SET(headers
descriptors/kaze/descriptor_kaze.h
descriptors/akaze/descriptor_akaze.h
descriptors/latch/descriptor_latch.h
descriptors/freak/descriptor_freak.h
descriptors/freak/descriptor_freak.h
descriptors/brief/descriptor_brief.h
matchers/matcher_factory.h
matchers/matcher_base.h)
......
#include "descriptor_brief.h"
namespace vision_utils {
DescriptorBRIEF::DescriptorBRIEF(void)
{}
DescriptorBRIEF::~DescriptorBRIEF(void)
{}
} /* namespace vision_utils */
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("BRIEF", DescriptorBRIEF);
} /* namespace vision_utils */
#ifndef _DESCRIPTOR_BRIEF_H_
#define _DESCRIPTOR_BRIEF_H_
#include "../descriptor_base.h"
#include "../descriptor_factory.h"
// yaml-cpp library
#ifdef USING_YAML
#include <yaml-cpp/yaml.h>
#endif
namespace vision_utils {
// Create all pointers
VU_PTR_TYPEDEFS(DescriptorBRIEF);
VU_PTR_TYPEDEFS(DescriptorParamsBRIEF);
/** \brief Class parameters
*
*/
struct DescriptorParamsBRIEF: public ParamsBase
{
int bytes = 32; // Legth of the descriptor in bytes, valid values are: 16, 32 (default) or 64 .
bool use_orientation = false; // Sample patterns using keypoints orientation, disabled by default.
};
/** \brief DETECTOR class
*
*/
class DescriptorBRIEF : public DescriptorBase {
public:
DescriptorBRIEF();
virtual ~DescriptorBRIEF(void);
// Factory method
static DescriptorBasePtr create(const std::string& _unique_name, const ParamsBasePtr _params);
private:
void defineDescriptor(const ParamsBasePtr _params);
};
/*
* brief Define detector
*/
inline void DescriptorBRIEF::defineDescriptor(const ParamsBasePtr _params)
{
DescriptorParamsBRIEFPtr params_ptr = std::static_pointer_cast<DescriptorParamsBRIEF>(_params);
descriptor_ = cv::xfeatures2d::BriefDescriptorExtractor::create(params_ptr->bytes,
params_ptr->use_orientation);
}
/*
* brief Create object in factory
*/
inline DescriptorBasePtr DescriptorBRIEF::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
DescriptorBRIEFPtr det_ptr = std::make_shared<DescriptorBRIEF>();
det_ptr->setName(_unique_name);
det_ptr->defineDescriptor(_params);
return det_ptr;
}
} /* namespace vision_utils */
#endif /* _DESCRIPTOR_BRIEF_H_ */
#include "descriptor_brief.h"
#ifdef USING_YAML
// yaml-cpp library
#include <yaml-cpp/yaml.h>
namespace vision_utils
{
namespace
{
static ParamsBasePtr createParamsBRIEFDescriptor(const std::string & _filename_dot_yaml)
{
DescriptorParamsBRIEFPtr params_ptr = std::make_shared<DescriptorParamsBRIEF>();
using std::string;
using YAML::Node;
Node yaml_params = YAML::LoadFile(_filename_dot_yaml);
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "BRIEF")
{
params_ptr->bytes = d_yaml["bytes"].as<int>();
params_ptr->use_orientation = d_yaml["use_orientation"].as<bool>();
}else
{
std::cerr << "Bad configuration file. Wrong type " << d_yaml["type"].as<string>() << std::endl;
return nullptr;
}
}
return params_ptr;
}
// Register in the SensorFactory
const bool registered_desBRIEF_params = ParamsFactory::get().registerCreator("BRIEF DES", createParamsBRIEFDescriptor);
} /* namespace [unnamed] */
} /* namespace vision_utils */
#endif /* IF USING_YAML */
......@@ -30,7 +30,7 @@
#include "../descriptors/akaze/descriptor_akaze.h"
#include "../descriptors/latch/descriptor_latch.h"
#include "../descriptors/freak/descriptor_freak.h"
//#include "../descriptors/brief/descriptor_brief.h"
#include "../descriptors/brief/descriptor_brief.h"
//#include "../descriptors/daisy/descriptor_daisy.h"
//#include "../descriptors/lucid/descriptor_lucid.h"
......@@ -106,8 +106,8 @@ int main(void)
des_ptr = std::static_pointer_cast<DescriptorLATCH>(des_ptr);
else if (des_name.compare("FREAK") == 0)
des_ptr = std::static_pointer_cast<DescriptorFREAK>(des_ptr);
// else if (des_name.compare("BRIEF") == 0)
// des_ptr = std::static_pointer_cast<DescriptorBRIEF>(des_ptr);
else if (des_name.compare("BRIEF") == 0)
des_ptr = std::static_pointer_cast<DescriptorBRIEF>(des_ptr);
// else if (des_name.compare("DAISY") == 0)
// des_ptr = std::static_pointer_cast<DescriptorDAISY>(des_ptr);
// else if (des_name.compare("LUCID") == 0)
......
sensor:
type: "USB_CAM"
descriptor:
type: "BRIEF"
bytes: 32
use_orientation: false
\ No newline at end of file
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