KeyPointTest.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // KeyPointTest.swift
  3. //
  4. // Created by Giles Payne on 2020/01/31.
  5. //
  6. import XCTest
  7. import OpenCV
  8. class KeyPointTest: OpenCVTestCase {
  9. let angle:Float = 30
  10. let classId:Int32 = 1
  11. let octave:Int32 = 1
  12. let response:Float = 2.0
  13. let size:Float = 3.0
  14. let x:Float = 1.0
  15. let y:Float = 2.0
  16. func testKeyPoint() {
  17. let keyPoint = KeyPoint()
  18. assertPoint2fEquals(Point2f(x: 0, y: 0), keyPoint.pt, OpenCVTestCase.FEPS)
  19. }
  20. func testKeyPointFloatFloatFloat() {
  21. let keyPoint = KeyPoint(x: x, y: y, size: size)
  22. assertPoint2fEquals(Point2f(x: 1, y: 2), keyPoint.pt, OpenCVTestCase.FEPS)
  23. }
  24. func testKeyPointFloatFloatFloatFloat() {
  25. let keyPoint = KeyPoint(x: x, y: y, size: size, angle: 10.0)
  26. XCTAssertEqual(10.0, keyPoint.angle);
  27. }
  28. func testKeyPointFloatFloatFloatFloatFloat() {
  29. let keyPoint = KeyPoint(x: x, y: y, size: size, angle: 1.0, response: 1.0)
  30. XCTAssertEqual(1.0, keyPoint.response)
  31. }
  32. func testKeyPointFloatFloatFloatFloatFloatInt() {
  33. let keyPoint = KeyPoint(x: x, y: y, size: size, angle: 1.0, response: 1.0, octave: 1)
  34. XCTAssertEqual(1, keyPoint.octave)
  35. }
  36. func testKeyPointFloatFloatFloatFloatFloatIntInt() {
  37. let keyPoint = KeyPoint(x: x, y: y, size: size, angle: 1.0, response: 1.0, octave: 1, classId: 1)
  38. XCTAssertEqual(1, keyPoint.classId)
  39. }
  40. func testToString() {
  41. let keyPoint = KeyPoint(x: x, y: y, size: size, angle: angle, response: response, octave: octave, classId: classId)
  42. let actual = "\(keyPoint)"
  43. let expected = "KeyPoint { pt: Point2f {1.000000,2.000000}, size: 3.000000, angle: 30.000000, response: 2.000000, octave: 1, classId: 1}"
  44. XCTAssertEqual(expected, actual)
  45. }
  46. }