1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 21:33:04 +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
@@ -10,11 +10,11 @@ import org.opencv.features2d.SIFT;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import org.opencv.imgproc.Imgproc;
import org.opencv.features2d.Feature2D;
import org.opencv.features2d.SIFT;
public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
Feature2D extractor;
SIFT extractor;
KeyPoint keypoint;
int matSize;
Mat truth;
@@ -43,7 +43,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
117, 112, 117, 76, 117, 54, 117, 25, 29, 22, 117, 117, 16, 11, 14,
1, 0, 0, 22, 26, 0, 0, 0, 0, 1, 4, 15, 2, 47, 8, 0, 0, 82, 56, 31,
17, 81, 12, 0, 0, 26, 23, 18, 23, 0, 0, 0, 0, 0, 0, 0, 0
);
);
}
};
}
@@ -76,23 +76,23 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
public void testEmpty() {
// assertFalse(extractor.empty());
fail("Not yet implemented"); //SIFT does not override empty() method
fail("Not yet implemented"); // SIFT does not override empty() method
}
public void testRead() {
fail("Not yet implemented");
}
public void testReadYml() {
String filename = OpenCVTestRunner.getTempFileName("yml");
writeFile(filename, "%YAML:1.0\n---\nname: \"Feature2D.SIFT\"\nnfeatures: 100\nnOctaveLayers: 4\ncontrastThreshold: 5.0000000000000001e-02\nedgeThreshold: 11\nsigma: 1.7\ndescriptorType: 5\n");
public void testWrite() {
String filename = OpenCVTestRunner.getTempFileName("xml");
extractor.read(filename);
extractor.write(filename);
assertEquals(128, extractor.descriptorSize());
// String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.SIFT</name>\n<contrastThreshold>4.0000000000000001e-02</contrastThreshold>\n<edgeThreshold>10.</edgeThreshold>\n<nFeatures>0</nFeatures>\n<nOctaveLayers>3</nOctaveLayers>\n<sigma>1.6000000000000001e+00</sigma>\n</opencv_storage>\n";
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n</opencv_storage>\n";
String actual = readFile(filename);
actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
assertEquals(truth, actual);
assertEquals(100, extractor.getNFeatures());
assertEquals(4, extractor.getNOctaveLayers());
assertEquals(0.05, extractor.getContrastThreshold());
assertEquals(11., extractor.getEdgeThreshold());
assertEquals(1.7, extractor.getSigma());
assertEquals(5, extractor.descriptorType());
}
public void testWriteYml() {
@@ -100,8 +100,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
extractor.write(filename);
// String truth = "%YAML:1.0\n---\nname: \"Feature2D.SIFT\"\ncontrastThreshold: 4.0000000000000001e-02\nedgeThreshold: 10.\nnFeatures: 0\nnOctaveLayers: 3\nsigma: 1.6000000000000001e+00\n";
String truth = "%YAML:1.0\n---\n";
String truth = "%YAML:1.0\n---\nname: \"Feature2D.SIFT\"\nnfeatures: 0\nnOctaveLayers: 3\ncontrastThreshold: 4.0000000000000001e-02\nedgeThreshold: 10.\nsigma: 1.6000000000000001e+00\ndescriptorType: 5\n";
String actual = readFile(filename);
actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
assertEquals(truth, actual);