AGASTFeatureDetectorTest.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package org.opencv.test.features2d;
  2. import org.opencv.test.OpenCVTestCase;
  3. import org.opencv.test.OpenCVTestRunner;
  4. import org.opencv.features2d.AgastFeatureDetector;
  5. public class AGASTFeatureDetectorTest extends OpenCVTestCase {
  6. AgastFeatureDetector detector;
  7. @Override
  8. protected void setUp() throws Exception {
  9. super.setUp();
  10. detector = AgastFeatureDetector.create(); // default (10,true,3)
  11. }
  12. public void testCreate() {
  13. assertNotNull(detector);
  14. }
  15. public void testDetectListOfMatListOfListOfKeyPoint() {
  16. fail("Not yet implemented");
  17. }
  18. public void testDetectListOfMatListOfListOfKeyPointListOfMat() {
  19. fail("Not yet implemented");
  20. }
  21. public void testDetectMatListOfKeyPoint() {
  22. fail("Not yet implemented");
  23. }
  24. public void testDetectMatListOfKeyPointMat() {
  25. fail("Not yet implemented");
  26. }
  27. public void testEmpty() {
  28. fail("Not yet implemented");
  29. }
  30. public void testRead() {
  31. String filename = OpenCVTestRunner.getTempFileName("xml");
  32. writeFile(filename, "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.AgastFeatureDetector</name>\n<threshold>11</threshold>\n<nonmaxSuppression>0</nonmaxSuppression>\n<type>2</type>\n</opencv_storage>\n");
  33. detector.read(filename);
  34. assertEquals(11, detector.getThreshold());
  35. assertEquals(false, detector.getNonmaxSuppression());
  36. assertEquals(2, detector.getType());
  37. }
  38. public void testReadYml() {
  39. String filename = OpenCVTestRunner.getTempFileName("yml");
  40. writeFile(filename, "%YAML:1.0\n---\nname: \"Feature2D.AgastFeatureDetector\"\nthreshold: 11\nnonmaxSuppression: 0\ntype: 2\n");
  41. detector.read(filename);
  42. assertEquals(11, detector.getThreshold());
  43. assertEquals(false, detector.getNonmaxSuppression());
  44. assertEquals(2, detector.getType());
  45. }
  46. public void testWrite() {
  47. String filename = OpenCVTestRunner.getTempFileName("xml");
  48. detector.write(filename);
  49. String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.AgastFeatureDetector</name>\n<threshold>10</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n<type>3</type>\n</opencv_storage>\n";
  50. String actual = readFile(filename);
  51. actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
  52. assertEquals(truth, actual);
  53. }
  54. public void testWriteYml() {
  55. String filename = OpenCVTestRunner.getTempFileName("yml");
  56. detector.write(filename);
  57. String truth = "%YAML:1.0\n---\nname: \"Feature2D.AgastFeatureDetector\"\nthreshold: 10\nnonmaxSuppression: 1\ntype: 3\n";
  58. String actual = readFile(filename);
  59. actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
  60. assertEquals(truth, actual);
  61. }
  62. }