Scalar.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // Scalar.h
  3. //
  4. // Created by Giles Payne on 2019/10/06.
  5. //
  6. #pragma once
  7. #ifdef __cplusplus
  8. #import "opencv2/core.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. NS_ASSUME_NONNULL_BEGIN
  14. /**
  15. * Represents a four element vector
  16. */
  17. CV_EXPORTS @interface Scalar : NSObject
  18. #pragma mark - Properties
  19. @property(readonly) NSArray<NSNumber*>* val;
  20. #ifdef __cplusplus
  21. @property(readonly) cv::Scalar& nativeRef;
  22. #endif
  23. #pragma mark - Constructors
  24. - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  25. - (instancetype)initWithV0:(double)v0 v1:(double)v1 v2:(double)v2 v3:(double)v3 NS_SWIFT_NAME(init(_:_:_:_:));
  26. - (instancetype)initWithV0:(double)v0 v1:(double)v1 v2:(double)v2 NS_SWIFT_NAME(init(_:_:_:));
  27. - (instancetype)initWithV0:(double)v0 v1:(double)v1 NS_SWIFT_NAME(init(_:_:));
  28. - (instancetype)initWithV0:(double)v0 NS_SWIFT_NAME(init(_:));
  29. #ifdef __cplusplus
  30. + (instancetype)fromNative:(cv::Scalar&)nativeScalar;
  31. #endif
  32. #pragma mark - Methods
  33. /**
  34. * Creates a scalar with all elements of the same value
  35. * @param v The value to set each element to
  36. */
  37. + (Scalar*)all:(double)v;
  38. /**
  39. * Calculates per-element product with another Scalar and a scale factor
  40. * @param it The other Scalar
  41. * @param scale The scale factor
  42. */
  43. - (Scalar*)mul:(Scalar*)it scale:(double)scale;
  44. /**
  45. * Calculates per-element product with another Scalar
  46. * @param it The other Scalar
  47. */
  48. - (Scalar*)mul:(Scalar*)it;
  49. /**
  50. * Returns (v0, -v1, -v2, -v3)
  51. */
  52. - (Scalar*)conj;
  53. /**
  54. * Returns true iff v1 == v2 == v3 == 0
  55. */
  56. - (BOOL)isReal;
  57. #pragma mark - Common Methods
  58. /**
  59. * Clone object
  60. */
  61. - (Scalar*)clone;
  62. /**
  63. * Compare for equality
  64. * @param other Object to compare
  65. */
  66. - (BOOL)isEqual:(nullable id)object;
  67. /**
  68. * Calculate hash value for this object
  69. */
  70. - (NSUInteger)hash;
  71. /**
  72. * Returns a string that describes the contents of the object
  73. */
  74. - (NSString*)description;
  75. @end
  76. NS_ASSUME_NONNULL_END