Skip to content
Snippets Groups Projects
Commit cdfd4cfb authored by Jaime Tarrasó Martínez's avatar Jaime Tarrasó Martínez
Browse files

Add processor_image_params.h to store parameters used by both image

processors
parent 7db51dc1
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ image:
detector-descriptor:
type: "ORB" # This affects the structure below. See processor_image_BRISK.yaml for another example
nominal pattern radius: 2 # 0 # 18?
nfeatures: 500
scale factor: 1.2
nlevels: 8
......@@ -27,7 +26,7 @@ matcher:
active search:
grid width: 10
grid height: 8
separation: 0
separation: 5
algorithm:
maximum new features: 40
......
......@@ -16,7 +16,8 @@ int main(int argc, char** argv)
const char * filename;
if (argc == 1)
{
filename = "/home/jtarraso/Vídeos/gray.mp4";
// filename = "/home/jtarraso/Vídeos/gray.mp4";
filename = "/home/jtarraso/Imágenes/Test_ORB.png";
capture.open(filename);
}
else if (std::string(argv[1]) == "0")
......
......@@ -96,7 +96,6 @@ int main()
{
DetectorDescriptorParamsOrb* dd = new DetectorDescriptorParamsOrb;
dd->type = DD_ORB;
dd->nominal_pattern_radius = dd_yaml["nominal pattern radius"].as<unsigned int>();
dd->nfeatures = dd_yaml["nfeatures"].as<unsigned int>();
dd->scaleFactor = dd_yaml["scale factor"].as<float>();
dd->nlevels = dd_yaml["nlevels"].as<unsigned int>();
......
......@@ -25,8 +25,8 @@ ProcessorImage::ProcessorImage(ProcessorParamsImage _params) :
params_brisk->octaves, //
params_brisk->pattern_scale);
detector_descriptor_params_.pattern_radius_ = std::max((unsigned int)((_dd_params->nominal_pattern_radius)*pow(2,params_brisk->octaves)),
(unsigned int)((_dd_params->nominal_pattern_radius)*params_brisk->pattern_scale));
detector_descriptor_params_.pattern_radius_ = std::max((unsigned int)((params_brisk->nominal_pattern_radius)*pow(2,params_brisk->octaves)),
(unsigned int)((params_brisk->nominal_pattern_radius)*params_brisk->pattern_scale));
detector_descriptor_params_.size_bits_ = detector_descriptor_ptr_->descriptorSize() * 8;
......@@ -44,9 +44,7 @@ ProcessorImage::ProcessorImage(ProcessorParamsImage _params) :
params_orb->scoreType, //
params_orb->patchSize);
detector_descriptor_params_.pattern_radius_ =
(unsigned int)( (_dd_params->nominal_pattern_radius) * pow(params_orb->scaleFactor, params_orb->nlevels-1) );
detector_descriptor_params_.pattern_radius_ = params_orb->edgeThreshold;
detector_descriptor_params_.size_bits_ = detector_descriptor_ptr_->descriptorSize() * 8;
break;
......
......@@ -9,6 +9,8 @@
#include "active_search.h"
#include "processor_tracker_feature.h"
#include "constraint_epipolar.h"
#include "processor_image_params.h"
// OpenCV includes
#include "opencv2/features2d/features2d.hpp"
......@@ -24,83 +26,6 @@
namespace wolf {
enum DetectorDescriptorType
{
DD_BRISK,
DD_ORB
};
struct DetectorDescriptorParamsBase
{
DetectorDescriptorType type; ///< Type of algorithm. Accepted values in wolf.h
unsigned int nominal_pattern_radius = 18; ///< Radius of the pattern before scaling
//should this be here? doesn't it depend on the descriptor?
};
struct DetectorDescriptorParamsBrisk : public DetectorDescriptorParamsBase
{
unsigned int threshold=30; ///< on the keypoint strength to declare it key-point
unsigned int octaves=0; ///< Multi-scale evaluation. 0: no multi-scale
float pattern_scale=1.0f; ///< Scale of the base pattern wrt the nominal one
};
struct DetectorDescriptorParamsOrb : public DetectorDescriptorParamsBase
{
unsigned int nfeatures=500; ///< Nbr of features to extract
float scaleFactor=1.2f; ///< Scale factor between two consecutive scales of the image pyramid
unsigned int nlevels=1;///< Number of levels in the pyramid. Default: 8
unsigned int edgeThreshold=4; ///< ? //Default: 31
unsigned int firstLevel=0;
unsigned int WTA_K=2;
unsigned int scoreType=cv::ORB::HARRIS_SCORE; ///< Type of score to rank the detected points
unsigned int patchSize=31;
};
struct ProcessorParamsImage : public ProcessorParamsBase
{
struct Image
{
unsigned int width; ///< image width (horizontal dimension or nbr of columns)
unsigned int height; ///< image height (vertical dimension or nbr of rows)
}image;
DetectorDescriptorParamsBase* detector_descriptor_params_ptr;
// struct Detector
// {
// unsigned int threshold; ///< on the keypoint strength to declare it key-point
// unsigned int threshold_new_features; ///< on the keypoint strength to declare it key-point
// unsigned int octaves; ///< Multi-scale evaluation. 0: no multi-scale
// unsigned int nominal_pattern_radius; ///< Radius of the detector pattern before scaling
// unsigned int pattern_radius; ///< radius of the pattern used to detect a key-point at pattern_scale = 1.0 and octaves = 0
// }detector;
// struct Descriptor
// {
// unsigned int nominal_pattern_radius; ///< Radius of the descriptor pattern before scaling
// float pattern_scale; ///< Scale of the base pattern wrt the nominal one
// unsigned int pattern_radius; ///< radius of the pattern used to describe a key-point at pattern_scale = 1.0 and octaves = 0
// unsigned int size_bits; ///< length of the descriptor vector in bits
// }descriptor;
struct Matcher
{
Scalar min_normalized_score; ///< [-1..0]: awful match; 1: perfect match; out of [-1,1]: error
int similarity_norm; ///< Norm used to measure the distance between two descriptors
unsigned int roi_width; ///< Width of the roi used in tracking
unsigned int roi_height; ///< Height of the roi used in tracking
}matcher;
struct Active_search
{
unsigned int grid_width; ///< cells per horizontal dimension of image
unsigned int grid_height; ///< cells per vertical dimension of image
unsigned int separation; ///< Distance between the border of the cell and the border of the associated ROI
}active_search;
struct Algorithm
{
unsigned int max_new_features; ///< Max nbr. of features to detect in one frame
unsigned int min_features_for_keyframe; ///< minimum nbr. of features to vote for keyframe
}algorithm;
};
class ProcessorImage : public ProcessorTrackerFeature
{
......
......@@ -31,8 +31,8 @@ ProcessorImageLandmark::ProcessorImageLandmark(ProcessorParamsImage _params) :
params_brisk->octaves, //
params_brisk->pattern_scale);
detector_descriptor_params_.pattern_radius_ = std::max((unsigned int)((_dd_params->nominal_pattern_radius)*pow(2,params_brisk->octaves)),
(unsigned int)((_dd_params->nominal_pattern_radius)*params_brisk->pattern_scale));
detector_descriptor_params_.pattern_radius_ = std::max((unsigned int)((params_brisk->nominal_pattern_radius)*pow(2,params_brisk->octaves)),
(unsigned int)((params_brisk->nominal_pattern_radius)*params_brisk->pattern_scale));
detector_descriptor_params_.size_bits_ = detector_descriptor_ptr_->descriptorSize() * 8;
......@@ -50,13 +50,9 @@ ProcessorImageLandmark::ProcessorImageLandmark(ProcessorParamsImage _params) :
params_orb->scoreType, //
params_orb->patchSize);
detector_descriptor_params_.pattern_radius_ =
(unsigned int)( (_dd_params->nominal_pattern_radius) * pow(params_orb->scaleFactor, params_orb->nlevels-1) );
std::cout << "nominal pattern radius: " << _dd_params->nominal_pattern_radius << std::endl;
std::cout << "scale factor: " << params_orb->scaleFactor << std::endl;
std::cout << "nlevels: " << params_orb->nlevels << std::endl;
std::cout << "===================edgeTh size: " << params_orb->edgeThreshold << std::endl;
detector_descriptor_params_.pattern_radius_ = params_orb->edgeThreshold;
detector_descriptor_params_.size_bits_ = detector_descriptor_ptr_->descriptorSize() * 8;
break;
......@@ -465,7 +461,7 @@ void ProcessorImageLandmark::inflateRoi(cv::Rect& _roi)
void ProcessorImageLandmark::adaptRoi(cv::Mat& _image_roi, cv::Mat _image, cv::Rect& _roi)
{
//inflateRoi(_roi);
inflateRoi(_roi);
trimRoi(_roi);
tracker_roi_inflated_.push_back(_roi);
......
......@@ -9,8 +9,8 @@
#include "state_quaternion.h"
#include "active_search.h"
#include "processor_tracker_landmark.h"
#include "constraint_epipolar.h"
#include "landmark_AHP.h"
#include "processor_image_params.h"
// OpenCV includes
#include "opencv2/features2d/features2d.hpp"
......@@ -25,68 +25,6 @@
namespace wolf {
enum DetectorDescriptorType
{
DD_BRISK,
DD_ORB
};
struct DetectorDescriptorParamsBase
{
DetectorDescriptorType type; ///< Type of algorithm. Accepted values in wolf.h
unsigned int nominal_pattern_radius = 0; ///< Radius of the pattern before scaling //18 for brisk
// should this be here? doesn't it depend on the descriptor?
};
struct DetectorDescriptorParamsBrisk : public DetectorDescriptorParamsBase
{
unsigned int threshold=30; ///< on the keypoint strength to declare it key-point
unsigned int octaves=0; ///< Multi-scale evaluation. 0: no multi-scale
float pattern_scale=1.0f; ///< Scale of the base pattern wrt the nominal one
};
struct DetectorDescriptorParamsOrb : public DetectorDescriptorParamsBase
{
unsigned int nfeatures=500; ///< Nbr of features to extract
float scaleFactor=1.2f; ///< Scale factor between two consecutive scales of the image pyramid
unsigned int nlevels=1;///< Number of levels in the pyramid. Default: 8
unsigned int edgeThreshold=4; ///< ? //Default: 31
unsigned int firstLevel=0;
unsigned int WTA_K=2;
unsigned int scoreType=cv::ORB::HARRIS_SCORE; ///< Type of score to rank the detected points
unsigned int patchSize=31;
};
struct ProcessorParamsImage : public ProcessorParamsBase
{
struct Image
{
unsigned int width; ///< image width (horizontal dimension or nbr of columns)
unsigned int height; ///< image height (vertical dimension or nbr of rows)
}image;
DetectorDescriptorParamsBase* detector_descriptor_params_ptr;
struct Matcher
{
Scalar min_normalized_score; ///< [-1..0]: awful match; 1: perfect match; out of [-1,1]: error
int similarity_norm; ///< Norm used to measure the distance between two descriptors
unsigned int roi_width; ///< Width of the roi used in tracking
unsigned int roi_height; ///< Height of the roi used in tracking
}matcher;
struct Active_search
{
unsigned int grid_width; ///< cells per horizontal dimension of image
unsigned int grid_height; ///< cells per vertical dimension of image
unsigned int separation; ///< Distance between the border of the cell and the border of the associated ROI
}active_search;
struct Algorithm
{
unsigned int max_new_features; ///< Max nbr. of features to detect in one frame
unsigned int min_features_for_keyframe; ///< minimum nbr. of features to vote for keyframe
}algorithm;
};
class ProcessorImageLandmark : public ProcessorTrackerLandmark
{
protected:
......
#ifndef PROCESSOR_IMAGE_PARAMS_H
#define PROCESSOR_IMAGE_PARAMS_H
namespace wolf
{
enum DetectorDescriptorType
{
DD_BRISK,
DD_ORB
};
struct DetectorDescriptorParamsBase
{
DetectorDescriptorType type; ///< Type of algorithm. Accepted values in wolf.h
};
struct DetectorDescriptorParamsBrisk : public DetectorDescriptorParamsBase
{
unsigned int threshold=30; ///< on the keypoint strength to declare it key-point
unsigned int octaves=0; ///< Multi-scale evaluation. 0: no multi-scale
float pattern_scale=1.0f; ///< Scale of the base pattern wrt the nominal one
unsigned int nominal_pattern_radius = 18; ///< Radius of the pattern before scaling //18 for brisk
};
struct DetectorDescriptorParamsOrb : public DetectorDescriptorParamsBase
{
unsigned int nfeatures=500; ///< Nbr of features to extract
float scaleFactor=1.2f; ///< Scale factor between two consecutive scales of the image pyramid
unsigned int nlevels=8;///< Number of levels in the pyramid. Default: 8
unsigned int edgeThreshold=16; ///< Default: 16
unsigned int firstLevel=0;
unsigned int WTA_K=2;
unsigned int scoreType=cv::ORB::HARRIS_SCORE; ///< Type of score to rank the detected points
unsigned int patchSize=31;
};
struct ProcessorParamsImage : public ProcessorParamsBase
{
struct Image
{
unsigned int width; ///< image width (horizontal dimension or nbr of columns)
unsigned int height; ///< image height (vertical dimension or nbr of rows)
}image;
DetectorDescriptorParamsBase* detector_descriptor_params_ptr;
struct Matcher
{
Scalar min_normalized_score; ///< [-1..0]: awful match; 1: perfect match; out of [-1,1]: error
int similarity_norm; ///< Norm used to measure the distance between two descriptors
unsigned int roi_width; ///< Width of the roi used in tracking
unsigned int roi_height; ///< Height of the roi used in tracking
}matcher;
struct Active_search
{
unsigned int grid_width; ///< cells per horizontal dimension of image
unsigned int grid_height; ///< cells per vertical dimension of image
unsigned int separation; ///< Distance between the border of the cell and the border of the associated ROI
}active_search;
struct Algorithm
{
unsigned int max_new_features; ///< Max nbr. of features to detect in one frame
unsigned int min_features_for_keyframe; ///< minimum nbr. of features to vote for keyframe
}algorithm;
};
}
#endif // PROCESSOR_IMAGE_PARAMS_H
......@@ -35,11 +35,11 @@ static ProcessorParamsBase* createProcessorParamsImage(const std::string & _file
{
DetectorDescriptorParamsOrb* dd = new DetectorDescriptorParamsOrb;
dd->type = DD_ORB;
dd->nominal_pattern_radius = dd_yaml["nominal pattern radius"].as<unsigned int>();
dd->nfeatures = dd_yaml["nfeatures"].as<unsigned int>();
dd->scaleFactor = dd_yaml["scale factor"].as<float>();
dd->nlevels = dd_yaml["nlevels"].as<unsigned int>();
dd->edgeThreshold = dd_yaml["edge threshold"].as<unsigned int>();
std::cout << "edgeThreshold: " << dd->edgeThreshold << std::endl;
dd->firstLevel = dd_yaml["first level"].as<unsigned int>();
dd->WTA_K = dd_yaml["WTA_K"].as<unsigned int>();
dd->scoreType = dd_yaml["score type"].as<int>(); // enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 };
......
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