1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +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
+48
View File
@@ -111,6 +111,24 @@ public:
void findScaleSpaceExtrema( const std::vector<Mat>& gauss_pyr, const std::vector<Mat>& dog_pyr,
std::vector<KeyPoint>& keypoints ) const;
void read( const FileNode& fn) CV_OVERRIDE;
void write( FileStorage& fs) const CV_OVERRIDE;
void setNFeatures(int maxFeatures) CV_OVERRIDE { nfeatures = maxFeatures; }
int getNFeatures() const CV_OVERRIDE { return nfeatures; }
void setNOctaveLayers(int nOctaveLayers_) CV_OVERRIDE { nOctaveLayers = nOctaveLayers_; }
int getNOctaveLayers() const CV_OVERRIDE { return nOctaveLayers; }
void setContrastThreshold(double contrastThreshold_) CV_OVERRIDE { contrastThreshold = contrastThreshold_; }
double getContrastThreshold() const CV_OVERRIDE { return contrastThreshold; }
void setEdgeThreshold(double edgeThreshold_) CV_OVERRIDE { edgeThreshold = edgeThreshold_; }
double getEdgeThreshold() const CV_OVERRIDE { return edgeThreshold; }
void setSigma(double sigma_) CV_OVERRIDE { sigma = sigma_; }
double getSigma() const CV_OVERRIDE { return sigma; }
protected:
CV_PROP_RW int nfeatures;
CV_PROP_RW int nOctaveLayers;
@@ -554,4 +572,34 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask,
}
}
void SIFT_Impl::read( const FileNode& fn)
{
// if node is empty, keep previous value
if (!fn["nfeatures"].empty())
fn["nfeatures"] >> nfeatures;
if (!fn["nOctaveLayers"].empty())
fn["nOctaveLayers"] >> nOctaveLayers;
if (!fn["contrastThreshold"].empty())
fn["contrastThreshold"] >> contrastThreshold;
if (!fn["edgeThreshold"].empty())
fn["edgeThreshold"] >> edgeThreshold;
if (!fn["sigma"].empty())
fn["sigma"] >> sigma;
if (!fn["descriptorType"].empty())
fn["descriptorType"] >> descriptor_type;
}
void SIFT_Impl::write( FileStorage& fs) const
{
if(fs.isOpened())
{
fs << "name" << getDefaultName();
fs << "nfeatures" << nfeatures;
fs << "nOctaveLayers" << nOctaveLayers;
fs << "contrastThreshold" << contrastThreshold;
fs << "edgeThreshold" << edgeThreshold;
fs << "sigma" << sigma;
fs << "descriptorType" << descriptor_type;
}
}
}