ORBFeatureDetectorTest.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package org.opencv.test.features2d;
  2. import org.junit.Assert;
  3. import org.opencv.core.CvType;
  4. import org.opencv.core.KeyPoint;
  5. import org.opencv.core.Mat;
  6. import org.opencv.core.MatOfKeyPoint;
  7. import org.opencv.core.Scalar;
  8. import org.opencv.features2d.Features2d;
  9. import org.opencv.features2d.ORB;
  10. import org.opencv.test.OpenCVTestCase;
  11. public class ORBFeatureDetectorTest extends OpenCVTestCase {
  12. public void testCreate() {
  13. fail("Not yet implemented");
  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. fail("Not yet implemented");
  32. }
  33. public void testWrite() {
  34. fail("Not yet implemented");
  35. }
  36. public void testDetectTwoPoints() {
  37. Mat img = new Mat(256,256, CvType.CV_8UC3, new Scalar(0,0,0));
  38. img.put(35, 40, 255,255, 255);
  39. img.put(152, 98, 200,0, 0);
  40. MatOfKeyPoint keypoints = new MatOfKeyPoint();
  41. ORB orb = ORB.create();
  42. Mat descriptors = new Mat();
  43. orb.detectAndCompute(img, new Mat(), keypoints, descriptors);
  44. KeyPoint[] keypointsArray = keypoints.toArray();
  45. assertEquals(2, keypointsArray.length);
  46. long x1 = Math.round(keypointsArray[0].pt.x);
  47. long y1 = Math.round(keypointsArray[0].pt.y);
  48. long x2 = Math.round(keypointsArray[1].pt.x);
  49. long y2 = Math.round(keypointsArray[1].pt.y);
  50. if (x2 > x1) {
  51. assertEquals(40, x1);
  52. assertEquals(35, y1);
  53. assertEquals(98, x2);
  54. assertEquals(152, y2);
  55. } else {
  56. assertEquals(40, x2);
  57. assertEquals(35, y2);
  58. assertEquals(98, x1);
  59. assertEquals(152, y1);
  60. }
  61. }
  62. }