1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #20367 from augustinmanecy:features2d-rw

**Merge with contrib**: https://github.com/opencv/opencv_contrib/pull/3003

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
- [x] The PR is proposed to proper branch
- [ ] There is reference to original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
augustinmanecy
2022-12-21 14:03:00 +01:00
committed by GitHub
parent 63b6b24cd0
commit 0bd54a60e9
28 changed files with 845 additions and 555 deletions
+63 -25
View File
@@ -54,7 +54,7 @@ namespace cv
class BRISK_Impl CV_FINAL : public BRISK
{
public:
explicit BRISK_Impl(int thresh=30, int octaves=3, float patternScale=1.0f);
explicit BRISK_Impl(int _threshold=30, int _octaves=3, float _patternScale=1.0f);
// custom setup
explicit BRISK_Impl(const std::vector<float> &radiusList, const std::vector<int> &numberList,
float dMax=5.85f, float dMin=8.2f, const std::vector<int> indexChange=std::vector<int>());
@@ -65,6 +65,9 @@ public:
virtual ~BRISK_Impl();
void read( const FileNode& fn) CV_OVERRIDE;
void write( FileStorage& fs) const CV_OVERRIDE;
int descriptorSize() const CV_OVERRIDE
{
return strings_;
@@ -99,6 +102,35 @@ public:
{
return octaves;
}
virtual void setPatternScale(float _patternScale) CV_OVERRIDE
{
patternScale = _patternScale;
std::vector<float> rList;
std::vector<int> nList;
// this is the standard pattern found to be suitable also
rList.resize(5);
nList.resize(5);
const double f = 0.85 * patternScale;
rList[0] = (float)(f * 0.);
rList[1] = (float)(f * 2.9);
rList[2] = (float)(f * 4.9);
rList[3] = (float)(f * 7.4);
rList[4] = (float)(f * 10.8);
nList[0] = 1;
nList[1] = 10;
nList[2] = 14;
nList[3] = 15;
nList[4] = 20;
generateKernel(rList, nList, (float)(5.85 * patternScale), (float)(8.2 * patternScale));
}
virtual float getPatternScale() const CV_OVERRIDE
{
return patternScale;
}
// call this to generate the kernel:
// circle of radius r (pixels), with n points;
@@ -122,6 +154,7 @@ protected:
// Feature parameters
CV_PROP_RW int threshold;
CV_PROP_RW int octaves;
CV_PROP_RW float patternScale;
// some helper structures for the Brisk pattern representation
struct BriskPatternPoint{
@@ -309,32 +342,12 @@ const float BriskScaleSpace::safetyFactor_ = 1.0f;
const float BriskScaleSpace::basicSize_ = 12.0f;
// constructors
BRISK_Impl::BRISK_Impl(int thresh, int octaves_in, float patternScale)
BRISK_Impl::BRISK_Impl(int _threshold, int _octaves, float _patternScale)
{
threshold = thresh;
octaves = octaves_in;
threshold = _threshold;
octaves = _octaves;
std::vector<float> rList;
std::vector<int> nList;
// this is the standard pattern found to be suitable also
rList.resize(5);
nList.resize(5);
const double f = 0.85 * patternScale;
rList[0] = (float)(f * 0.);
rList[1] = (float)(f * 2.9);
rList[2] = (float)(f * 4.9);
rList[3] = (float)(f * 7.4);
rList[4] = (float)(f * 10.8);
nList[0] = 1;
nList[1] = 10;
nList[2] = 14;
nList[3] = 15;
nList[4] = 20;
generateKernel(rList, nList, (float)(5.85 * patternScale), (float)(8.2 * patternScale));
setPatternScale(_patternScale);
}
BRISK_Impl::BRISK_Impl(const std::vector<float> &radiusList,
@@ -359,6 +372,31 @@ BRISK_Impl::BRISK_Impl(int thresh,
octaves = octaves_in;
}
void BRISK_Impl::read( const FileNode& fn)
{
// if node is empty, keep previous value
if (!fn["threshold"].empty())
fn["threshold"] >> threshold;
if (!fn["octaves"].empty())
fn["octaves"] >> octaves;
if (!fn["patternScale"].empty())
{
float _patternScale;
fn["patternScale"] >> _patternScale;
setPatternScale(_patternScale);
}
}
void BRISK_Impl::write( FileStorage& fs) const
{
if(fs.isOpened())
{
fs << "name" << getDefaultName();
fs << "threshold" << threshold;
fs << "octaves" << octaves;
fs << "patternScale" << patternScale;
}
}
void
BRISK_Impl::generateKernel(const std::vector<float> &radiusList,
const std::vector<int> &numberList,