mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
02385472b6
Objc binding * Initial work on Objective-C wrapper * Objective-C generator script; update manually generated wrappers * Add Mat tests * Core Tests * Imgproc wrapper generation and tests * Fixes for Imgcodecs wrapper * Miscellaneous fixes. Swift build support * Objective-C wrapper build/install * Add Swift wrappers for videoio/objdetect/feature2d * Framework build;iOS support * Fix toArray functions;Use enum types whenever possible * Use enum types where possible;prepare test build * Update test * Add test runner scripts for iOS and macOS * Add test scripts and samples * Build fixes * Fix build (cmake 3.17.x compatibility) * Fix warnings * Fix enum name conflicting handling * Add support for document generation with Jazzy * Swift/Native fast accessor functions * Add Objective-C wrapper for calib3d, dnn, ml, photo and video modules * Remove IntOut/FloatOut/DoubleOut classes * Fix iOS default test platform value * Fix samples * Revert default framework name to opencv2 * Add converter util functions * Fix failing test * Fix whitespace * Add handling for deprecated methods;fix warnings;define __OPENCV_BUILD * Suppress cmake warnings * Reduce severity of "jazzy not found" log message * Fix incorrect #include of compatibility header in ios.h * Use explicit returns in subscript/get implementation * Reduce minimum required cmake version to 3.15 for Objective-C/Swift binding
108 lines
2.0 KiB
Plaintext
108 lines
2.0 KiB
Plaintext
//
|
|
// Point2d.m
|
|
//
|
|
// Created by Giles Payne on 2019/10/09.
|
|
//
|
|
|
|
#import "Point2d.h"
|
|
#import "Rect2d.h"
|
|
#import "CVObjcUtil.h"
|
|
|
|
@implementation Point2d {
|
|
cv::Point2d native;
|
|
}
|
|
|
|
- (double)x {
|
|
return native.x;
|
|
}
|
|
|
|
- (void)setX:(double)val {
|
|
native.x = val;
|
|
}
|
|
|
|
- (double)y {
|
|
return native.y;
|
|
}
|
|
|
|
- (void)setY:(double)val {
|
|
native.y = val;
|
|
}
|
|
|
|
- (cv::Point2d&)nativeRef {
|
|
return native;
|
|
}
|
|
|
|
- (instancetype)init {
|
|
return [self initWithX:0 y:0];
|
|
}
|
|
|
|
- (instancetype)initWithX:(double)x y:(double)y {
|
|
self = [super init];
|
|
if (self) {
|
|
self.x = x;
|
|
self.y = y;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals {
|
|
self = [super init];
|
|
if (self) {
|
|
[self set:vals];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
+ (instancetype)fromNative:(cv::Point2d&)point {
|
|
return [[Point2d alloc] initWithX:point.x y:point.y];
|
|
}
|
|
|
|
- (void)update:(cv::Point2d&)point {
|
|
self.x = point.x;
|
|
self.y = point.y;
|
|
}
|
|
|
|
- (Point2d*) clone {
|
|
return [[Point2d alloc] initWithX:self.x y:self.y];
|
|
}
|
|
|
|
- (double)dot:(Point2d*)point {
|
|
return self.x * point.x + self.y * point.y;
|
|
}
|
|
|
|
- (void)set:(NSArray<NSNumber*>*)vals {
|
|
self.x = (vals != nil && vals.count > 0) ? vals[0].doubleValue : 0;
|
|
self.y = (vals != nil && vals.count > 1) ? vals[1].doubleValue : 0;
|
|
}
|
|
|
|
- (BOOL)isEqual:(id)other {
|
|
if (other == self) {
|
|
return YES;
|
|
} else if (![other isKindOfClass:[Point2d class]]) {
|
|
return NO;
|
|
} else {
|
|
Point2d* point = (Point2d*)other;
|
|
return self.x == point.x && self.y == point.y;
|
|
}
|
|
}
|
|
|
|
- (BOOL)inside:(Rect2d*)rect {
|
|
return [rect contains:self];
|
|
}
|
|
|
|
- (NSUInteger)hash {
|
|
int prime = 31;
|
|
uint32_t result = 1;
|
|
int64_t temp = DOUBLE_TO_BITS(self.x);
|
|
result = prime * result + (int32_t) (temp ^ (temp >> 32));
|
|
temp = DOUBLE_TO_BITS(self.y);
|
|
result = prime * result + (int32_t) (temp ^ (temp >> 32));
|
|
return result;
|
|
}
|
|
|
|
- (NSString *)description {
|
|
return [NSString stringWithFormat:@"Point2d {%lf,%lf}", self.x, self.y];
|
|
}
|
|
|
|
@end
|