diff --git a/modules/core/misc/objc/common/Range.h b/modules/core/misc/objc/common/Range.h index df0c01398f30..12bd48f54758 100644 --- a/modules/core/misc/objc/common/Range.h +++ b/modules/core/misc/objc/common/Range.h @@ -25,6 +25,9 @@ CV_EXPORTS @interface Range : NSObject @property int start; @property int end; +#ifdef __cplusplus +@property(readonly) cv::Range& nativeRef; +#endif #pragma mark - Constructors @@ -32,6 +35,10 @@ CV_EXPORTS @interface Range : NSObject - (instancetype)initWithStart:(int)start end:(int)end; - (instancetype)initWithVals:(NSArray*)vals; +#ifdef __cplusplus ++ (instancetype)fromNative:(cv::Range&)range; +#endif + #pragma mark - Methods /** diff --git a/modules/core/misc/objc/common/Range.m b/modules/core/misc/objc/common/Range.mm similarity index 81% rename from modules/core/misc/objc/common/Range.m rename to modules/core/misc/objc/common/Range.mm index a4e155214e94..55ba49e3ad0a 100644 --- a/modules/core/misc/objc/common/Range.m +++ b/modules/core/misc/objc/common/Range.mm @@ -1,12 +1,34 @@ // -// Range.m +// Range.mm // // Created by Giles Payne on 2019/10/08. // #import "Range.h" -@implementation Range +@implementation Range { + cv::Range native; +} + +- (int)start { + return native.start; +} + +- (void)setStart:(int)val { + native.start = val; +} + +- (int)end { + return native.end; +} + +- (void)setEnd:(int)val { + native.end = val; +} + +- (cv::Range&)nativeRef { + return native; +} - (instancetype)init { return [self initWithStart:0 end: 0]; @@ -29,6 +51,10 @@ - (instancetype)initWithVals:(NSArray*)vals { return self; } ++ (instancetype)fromNative:(cv::Range&)range { + return [[Range alloc] initWithStart:range.start end:range.end]; +} + - (void)set:(NSArray*)vals { self.start = (vals != nil && vals.count > 0) ? vals[0].intValue : 0; self.end = (vals != nil && vals.count > 1 ) ? vals[1].intValue : 0; diff --git a/modules/core/misc/objc/gen_dict.json b/modules/core/misc/objc/gen_dict.json index 58300255dcb3..e01b32d6dc33 100644 --- a/modules/core/misc/objc/gen_dict.json +++ b/modules/core/misc/objc/gen_dict.json @@ -167,7 +167,9 @@ "from_cpp": "[Point3i fromNative:%(n)s]" }, "Range": { - "objc_type": "Range*" + "objc_type": "Range*", + "to_cpp": "%(n)s.nativeRef", + "from_cpp": "[Range fromNative:%(n)s]" }, "Rect": { "objc_type": "Rect2i*",