MSERFeatureDetectorTest.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package org.opencv.test.features2d;
  2. import org.opencv.test.OpenCVTestCase;
  3. import org.opencv.test.OpenCVTestRunner;
  4. import org.opencv.features2d.MSER;
  5. public class MSERFeatureDetectorTest extends OpenCVTestCase {
  6. MSER detector;
  7. @Override
  8. protected void setUp() throws Exception {
  9. super.setUp();
  10. detector = MSER.create(); // default constructor have (5, 60, 14400, .25, .2, 200, 1.01, .003, 5)
  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 testReadYml() {
  31. String filename = OpenCVTestRunner.getTempFileName("yml");
  32. writeFile(filename, "%YAML:1.0\n---\nname: \"Feature2D.MSER\"\ndelta: 6\nminArea: 62\nmaxArea: 14402\nmaxVariation: .26\nminDiversity: .3\nmaxEvolution: 201\nareaThreshold: 1.02\nminMargin: 3.0e-3\nedgeBlurSize: 3\npass2Only: 1\n");
  33. detector.read(filename);
  34. assertEquals(6, detector.getDelta());
  35. assertEquals(62, detector.getMinArea());
  36. assertEquals(14402, detector.getMaxArea());
  37. assertEquals(.26, detector.getMaxVariation());
  38. assertEquals(.3, detector.getMinDiversity());
  39. assertEquals(201, detector.getMaxEvolution());
  40. assertEquals(1.02, detector.getAreaThreshold());
  41. assertEquals(0.003, detector.getMinMargin());
  42. assertEquals(3, detector.getEdgeBlurSize());
  43. assertEquals(true, detector.getPass2Only());
  44. }
  45. public void testWriteYml() {
  46. String filename = OpenCVTestRunner.getTempFileName("yml");
  47. detector.write(filename);
  48. String truth = "%YAML:1.0\n---\nname: \"Feature2D.MSER\"\ndelta: 5\nminArea: 60\nmaxArea: 14400\nmaxVariation: 0.25\nminDiversity: 0.20000000000000001\nmaxEvolution: 200\nareaThreshold: 1.01\nminMargin: 0.0030000000000000001\nedgeBlurSize: 5\npass2Only: 0\n";
  49. String actual = readFile(filename);
  50. actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
  51. assertEquals(truth, actual);
  52. }
  53. }