From 16561ed71e49b11d9790d3c161c65bdd3c0a2992 Mon Sep 17 00:00:00 2001 From: mtfrctl Date: Sun, 11 Oct 2020 19:16:03 +0900 Subject: [PATCH] Add data pointer bridge method to Mat for Objective-C/Swift --- modules/core/misc/objc/common/Mat.h | 1 + modules/core/misc/objc/common/Mat.mm | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/modules/core/misc/objc/common/Mat.h b/modules/core/misc/objc/common/Mat.h index 72f81dd9b7..229337f524 100644 --- a/modules/core/misc/objc/common/Mat.h +++ b/modules/core/misc/objc/common/Mat.h @@ -97,6 +97,7 @@ CV_EXPORTS @interface Mat : NSObject - (void)createEx:(NSArray*)sizes type:(int)type NS_SWIFT_NAME(create(sizes:type:)); - (void)copySize:(Mat*)mat; - (Mat*)cross:(Mat*)mat; +- (unsigned char*)dataPtr NS_SWIFT_NAME(dataPointer()); - (int)depth; - (Mat*)diag:(int)diagonal; - (Mat*)diag; diff --git a/modules/core/misc/objc/common/Mat.mm b/modules/core/misc/objc/common/Mat.mm index c075e26046..5d41a3622e 100644 --- a/modules/core/misc/objc/common/Mat.mm +++ b/modules/core/misc/objc/common/Mat.mm @@ -286,6 +286,10 @@ static bool updateIdx(cv::Mat* mat, std::vector& indices, int inc) { return [[Mat alloc] initWithNativeMat:new cv::Mat(_nativePtr->cross(*(cv::Mat*)mat.nativePtr))]; } +- (unsigned char*)dataPtr { + return _nativePtr->data; +} + - (int)depth { return _nativePtr->depth(); }