KeyPointTest.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package org.opencv.test.core;
  2. import org.opencv.core.Point;
  3. import org.opencv.core.KeyPoint;
  4. import org.opencv.test.OpenCVTestCase;
  5. public class KeyPointTest extends OpenCVTestCase {
  6. private float angle;
  7. private int classId;
  8. private KeyPoint keyPoint;
  9. private int octave;
  10. private float response;
  11. private float size;
  12. private float x;
  13. private float y;
  14. @Override
  15. protected void setUp() throws Exception {
  16. super.setUp();
  17. keyPoint = null;
  18. x = 1.0f;
  19. y = 2.0f;
  20. size = 3.0f;
  21. angle = 30.0f;
  22. response = 2.0f;
  23. octave = 1;
  24. classId = 1;
  25. }
  26. public void testKeyPoint() {
  27. keyPoint = new KeyPoint();
  28. assertPointEquals(new Point(0, 0), keyPoint.pt, EPS);
  29. }
  30. public void testKeyPointFloatFloatFloat() {
  31. keyPoint = new KeyPoint(x, y, size);
  32. assertPointEquals(new Point(1, 2), keyPoint.pt, EPS);
  33. }
  34. public void testKeyPointFloatFloatFloatFloat() {
  35. keyPoint = new KeyPoint(x, y, size, 10.0f);
  36. assertEquals(10.0f, keyPoint.angle);
  37. }
  38. public void testKeyPointFloatFloatFloatFloatFloat() {
  39. keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f);
  40. assertEquals(1.0f, keyPoint.response);
  41. }
  42. public void testKeyPointFloatFloatFloatFloatFloatInt() {
  43. keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1);
  44. assertEquals(1, keyPoint.octave);
  45. }
  46. public void testKeyPointFloatFloatFloatFloatFloatIntInt() {
  47. keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1, 1);
  48. assertEquals(1, keyPoint.class_id);
  49. }
  50. public void testToString() {
  51. keyPoint = new KeyPoint(x, y, size, angle, response, octave, classId);
  52. String actual = keyPoint.toString();
  53. String expected = "KeyPoint [pt={1.0, 2.0}, size=3.0, angle=30.0, response=2.0, octave=1, class_id=1]";
  54. assertEquals(expected, actual);
  55. }
  56. }