RotatedRect.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // RotatedRect.h
  3. //
  4. // Created by Giles Payne on 2019/12/26.
  5. //
  6. #pragma once
  7. #ifdef __cplusplus
  8. #import "opencv2/core.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. @class Point2f;
  13. @class Size2f;
  14. @class Rect2f;
  15. #import <Foundation/Foundation.h>
  16. NS_ASSUME_NONNULL_BEGIN
  17. /**
  18. * Represents a rotated rectangle on a plane
  19. */
  20. CV_EXPORTS @interface RotatedRect : NSObject
  21. #pragma mark - Properties
  22. @property Point2f* center;
  23. @property Size2f* size;
  24. @property double angle;
  25. #ifdef __cplusplus
  26. @property(readonly) cv::RotatedRect& nativeRef;
  27. #endif
  28. #pragma mark - Constructors
  29. - (instancetype)init;
  30. - (instancetype)initWithCenter:(Point2f*)center size:(Size2f*)size angle:(double)angle;
  31. - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  32. #ifdef __cplusplus
  33. + (instancetype)fromNative:(cv::RotatedRect&)rotatedRect;
  34. #endif
  35. #pragma mark - Methods
  36. /**
  37. * Returns the corner points of the rotated rectangle as an array
  38. */
  39. - (NSArray<Point2f*>*)points;
  40. /**
  41. * Returns the bounding (non-rotated) rectangle of the rotated rectangle
  42. */
  43. - (Rect2f*)boundingRect;
  44. /**
  45. * Set the rotated rectangle coordinates, dimensions and angle of rotation from the values of an array
  46. * @param vals The array of values from which to set the rotated rectangle coordinates, dimensions and angle of rotation
  47. */
  48. - (void)set:(NSArray<NSNumber*>*)vals NS_SWIFT_NAME(set(vals:));
  49. #pragma mark - Common Methods
  50. /**
  51. * Clone object
  52. */
  53. - (RotatedRect*)clone;
  54. /**
  55. * Compare for equality
  56. * @param other Object to compare
  57. */
  58. - (BOOL)isEqual:(nullable id)object;
  59. /**
  60. * Calculate hash value for this object
  61. */
  62. - (NSUInteger)hash;
  63. /**
  64. * Returns a string that describes the contents of the object
  65. */
  66. - (NSString*)description;
  67. @end
  68. NS_ASSUME_NONNULL_END