Merge pull request #17555 from komakai:objc-fix-sift
This commit is contained in:
@@ -15,8 +15,6 @@ typedef union { float f; int32_t i; } V32;
|
||||
#ifdef __cplusplus
|
||||
#import <vector>
|
||||
|
||||
#define MAKE_PTR(t) (*((cv::Ptr<t>*)self.nativePtr))
|
||||
|
||||
template <typename CV, typename OBJC> std::vector<CV> objc2cv(NSArray<OBJC*>* _Nonnull array, CV& (* _Nonnull converter)(OBJC* _Nonnull)) {
|
||||
std::vector<CV> ret;
|
||||
for (OBJC* obj in array) {
|
||||
|
||||
@@ -26,17 +26,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface Mat : NSObject
|
||||
|
||||
#ifdef __cplusplus
|
||||
@property(readonly) cv::Mat* nativePtr;
|
||||
@property(readonly) cv::Ptr<cv::Mat> nativePtr;
|
||||
@property(readonly) cv::Mat& nativeRef;
|
||||
#endif
|
||||
|
||||
#pragma mark - Constructors
|
||||
|
||||
- (instancetype)init;
|
||||
- (void)dealloc;
|
||||
#ifdef __cplusplus
|
||||
- (instancetype)initWithNativeMat:(cv::Mat*)nativeMat;
|
||||
+ (instancetype)fromNativePtr:(cv::Mat*)nativePtr;
|
||||
- (instancetype)initWithNativeMat:(cv::Ptr<cv::Mat>)nativeMat;
|
||||
+ (instancetype)fromNativePtr:(cv::Ptr<cv::Mat>)nativePtr;
|
||||
+ (instancetype)fromNative:(cv::Mat&)nativeRef;
|
||||
#endif
|
||||
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type;
|
||||
|
||||
@@ -39,39 +39,31 @@ static bool updateIdx(cv::Mat* mat, std::vector<int>& indices, int inc) {
|
||||
}
|
||||
|
||||
- (cv::Mat&)nativeRef {
|
||||
return *(cv::Mat*)_nativePtr;
|
||||
return *_nativePtr;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_nativePtr = new cv::Mat();
|
||||
_nativePtr = cv::Ptr<cv::Mat>(new cv::Mat());
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (_nativePtr != NULL) {
|
||||
_nativePtr->release();
|
||||
delete _nativePtr;
|
||||
}
|
||||
_nsdata = NULL;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeMat:(cv::Mat*)nativePtr {
|
||||
- (instancetype)initWithNativeMat:(cv::Ptr<cv::Mat>)nativePtr {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_nativePtr = new cv::Mat(*nativePtr);
|
||||
_nativePtr = nativePtr;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromNativePtr:(cv::Mat*)nativePtr {
|
||||
+ (instancetype)fromNativePtr:(cv::Ptr<cv::Mat>)nativePtr {
|
||||
return [[Mat alloc] initWithNativeMat:nativePtr];
|
||||
}
|
||||
|
||||
+ (instancetype)fromNative:(cv::Mat&)nativeRef {
|
||||
return [[Mat alloc] initWithNativeMat:&nativeRef];
|
||||
return [[Mat alloc] initWithNativeMat:cv::Ptr<cv::Mat>(new cv::Mat(nativeRef))];
|
||||
}
|
||||
|
||||
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type {
|
||||
|
||||
Reference in New Issue
Block a user