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
158 lines
6.9 KiB
Objective-C
158 lines
6.9 KiB
Objective-C
//
|
|
// Mat.h
|
|
//
|
|
// Created by Giles Payne on 2019/10/06.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
#import "opencv.hpp"
|
|
#endif
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
@class Size2i;
|
|
@class Scalar;
|
|
@class Range;
|
|
@class Rect2i;
|
|
@class Point2i;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/**
|
|
* The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array.
|
|
*/
|
|
@interface Mat : NSObject
|
|
|
|
#ifdef __cplusplus
|
|
@property(readonly) 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)fromNative:(cv::Mat&)nativeRef;
|
|
#endif
|
|
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type;
|
|
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type data:(NSData*)data;
|
|
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type data:(NSData*)data step:(long)step;
|
|
- (instancetype)initWithSize:(Size2i*)size type:(int)type;
|
|
- (instancetype)initWithSizes:(NSArray<NSNumber*>*)sizes type:(int)type;
|
|
- (instancetype)initWithRows:(int)rows cols:(int)cols type:(int)type scalar:(Scalar*)scalar;
|
|
- (instancetype)initWithSize:(Size2i*)size type:(int)type scalar:(Scalar*)scalar;
|
|
- (instancetype)initWithSizes:(NSArray<NSNumber*>*)sizes type:(int)type scalar:(Scalar*)scalar;
|
|
- (instancetype)initWithMat:(Mat*)mat rowRange:(Range*)rowRange colRange:(Range*)colRange;
|
|
- (instancetype)initWithMat:(Mat*)mat rowRange:(Range*)rowRange;
|
|
- (instancetype)initWithMat:(Mat*)mat ranges:(NSArray<Range*>*)ranges;
|
|
- (instancetype)initWithMat:(Mat*)mat rect:(Rect2i*)roi;
|
|
|
|
#pragma mark - Mat operations
|
|
|
|
- (Mat*)adjustRoiTop:(int)dtop bottom:(int)dbottom left:(int)dleft right:(int)dright NS_SWIFT_NAME(adjustRoi(top:bottom:left:right:));
|
|
- (void)assignTo:(Mat*)mat type:(int)type;
|
|
- (void)assignTo:(Mat*)mat;
|
|
- (BOOL)isSameMat:(Mat*)mat;
|
|
- (int)channels;
|
|
- (int)checkVector:(int)elemChannels depth:(int)depth requireContinuous:(BOOL) requireContinuous NS_SWIFT_NAME(checkVector(elemChannels:depth:requireContinuous:));
|
|
- (int)checkVector:(int)elemChannels depth:(int)depth NS_SWIFT_NAME(checkVector(elemChannels:depth:));
|
|
- (int)checkVector:(int)elemChannels NS_SWIFT_NAME(checkVector(elemChannels:));
|
|
- (Mat*)clone;
|
|
- (Mat*)col:(int)x;
|
|
- (Mat*)colRange:(int)start end:(int)end NS_SWIFT_NAME(colRange(start:end:));
|
|
- (Mat*)colRange:(Range*)range;
|
|
- (int)dims;
|
|
- (int)cols;
|
|
- (void)convertTo:(Mat*)mat rtype:(int)rtype alpha:(double)alpha beta:(double)beta;
|
|
- (void)convertTo:(Mat*)mat rtype:(int)rtype alpha:(double)alpha;
|
|
- (void)convertTo:(Mat*)mat rtype:(int)rtype;
|
|
- (void)copyTo:(Mat*)mat;
|
|
- (void)copyTo:(Mat*)mat mask:(Mat*)mask;
|
|
- (void)create:(int)rows cols:(int)cols type:(int)type NS_SWIFT_NAME(create(rows:cols:type:));
|
|
- (void)create:(Size2i*)size type:(int)type NS_SWIFT_NAME(create(size:type:));
|
|
- (void)createEx:(NSArray<NSNumber*>*)sizes type:(int)type NS_SWIFT_NAME(create(sizes:type:));
|
|
- (void)copySize:(Mat*)mat;
|
|
- (Mat*)cross:(Mat*)mat;
|
|
- (int)depth;
|
|
- (Mat*)diag:(int)diagonal;
|
|
- (Mat*)diag;
|
|
+ (Mat*)diag:(Mat*)diagonal;
|
|
- (double)dot:(Mat*)mat;
|
|
- (long)elemSize;
|
|
- (long)elemSize1;
|
|
- (BOOL)empty;
|
|
+ (Mat*)eye:(int)rows cols:(int)cols type:(int)type NS_SWIFT_NAME(eye(rows:cols:type:));
|
|
+ (Mat*)eye:(Size2i*)size type:(int)type NS_SWIFT_NAME(eye(size:type:));
|
|
- (Mat*)inv:(int)method;
|
|
- (Mat*)inv;
|
|
- (BOOL)isContinuous;
|
|
- (BOOL)isSubmatrix;
|
|
- (void)locateROI:(Size2i*)wholeSize ofs:(Point2i*)offset NS_SWIFT_NAME(locateROI(wholeSize:offset:));
|
|
- (Mat*)mul:(Mat*)mat scale:(double)scale;
|
|
- (Mat*)mul:(Mat*)mat;
|
|
+ (Mat*)ones:(int)rows cols:(int)cols type:(int)type NS_SWIFT_NAME(ones(rows:cols:type:));
|
|
+ (Mat*)ones:(Size2i*)size type:(int)type NS_SWIFT_NAME(ones(size:type:));
|
|
+ (Mat*)onesEx:(NSArray<NSNumber*>*)sizes type:(int)type NS_SWIFT_NAME(ones(sizes:type:));
|
|
- (void)push_back:(Mat*)mat;
|
|
- (Mat*)reshape:(int)channels rows:(int)rows NS_SWIFT_NAME(reshape(channels:rows:));
|
|
- (Mat*)reshape:(int)channels NS_SWIFT_NAME(reshape(channels:));
|
|
- (Mat*)reshape:(int)channels newshape:(NSArray<NSNumber*>*)newshape NS_SWIFT_NAME(reshape(channels:newshape:));
|
|
- (Mat*)row:(int)y;
|
|
- (Mat*)rowRange:(int)start end:(int)end NS_SWIFT_NAME(rowRange(start:end:));
|
|
- (Mat*)rowRange:(Range*)range;
|
|
- (int)rows;
|
|
- (Mat*)setToScalar:(Scalar*)scalar NS_SWIFT_NAME(setTo(scalar:));
|
|
- (Mat*)setToScalar:(Scalar*)scalar mask:(Mat*)mask NS_SWIFT_NAME(setTo(scalar:mask:));
|
|
- (Mat*)setToValue:(Mat*)value mask:(Mat*)mask NS_SWIFT_NAME(setTo(value:mask:));
|
|
- (Mat*)setToValue:(Mat*)value NS_SWIFT_NAME(setTo(value:));
|
|
- (Size2i*)size;
|
|
- (int)size:(int)dim;
|
|
- (long)step1:(int)dim;
|
|
- (long)step1;
|
|
- (Mat*)submat:(int)rowStart rowEnd:(int)rowEnd colStart:(int)colStart colEnd:(int)colEnd NS_SWIFT_NAME(submat(rowStart:rowEnd:colStart:colEnd:));
|
|
- (Mat*)submat:(Range*)rowRange colRange:(Range*)colRange NS_SWIFT_NAME(submat(rowRange:colRange:));
|
|
- (Mat*)submat:(NSArray<Range*>*)ranges NS_SWIFT_NAME(submat(ranges:));
|
|
- (Mat*)submatRoi:(Rect2i*)roi NS_SWIFT_NAME(submat(roi:));
|
|
- (Mat*)t;
|
|
- (long)total;
|
|
- (int)type;
|
|
+ (Mat*)zeros:(int)rows cols:(int)cols type:(int)type;
|
|
+ (Mat*)zeros:(Size2i*)size type:(int)type;
|
|
+ (Mat*)zerosEx:(NSArray<NSNumber*>*)sizes type:(int)type NS_SWIFT_NAME(zeros(sizes:type:));
|
|
- (NSString*)description;
|
|
- (NSString*)dump;
|
|
- (int)height;
|
|
- (int)width;
|
|
|
|
#pragma mark - Accessors
|
|
|
|
- (int)put:(int)row col:(int)col data:(NSArray<NSNumber*>*)data NS_REFINED_FOR_SWIFT;
|
|
- (int)put:(NSArray<NSNumber*>*)indices data:(NSArray<NSNumber*>*)data NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(int)row col:(int)col data:(NSMutableArray<NSNumber*>*)data NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(NSArray<NSNumber*>*)indices data:(NSMutableArray<NSNumber*>*)data NS_REFINED_FOR_SWIFT;
|
|
|
|
- (NSArray<NSNumber*>*)get:(int)row col:(int)col NS_REFINED_FOR_SWIFT;
|
|
- (NSArray<NSNumber*>*)get:(NSArray<NSNumber*>*)indices NS_REFINED_FOR_SWIFT;
|
|
|
|
- (int)get:(NSArray<NSNumber*>*)indices count:(int)count byteBuffer:(char*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(NSArray<NSNumber*>*)indices count:(int)count doubleBuffer:(double*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(NSArray<NSNumber*>*)indices count:(int)count floatBuffer:(float*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(NSArray<NSNumber*>*)indices count:(int)count intBuffer:(int*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)get:(NSArray<NSNumber*>*)indices count:(int)count shortBuffer:(short*)buffer NS_REFINED_FOR_SWIFT;
|
|
|
|
- (int)put:(NSArray<NSNumber*>*)indices count:(int)count byteBuffer:(const char*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)put:(NSArray<NSNumber*>*)indices count:(int)count doubleBuffer:(const double*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)put:(NSArray<NSNumber*>*)indices count:(int)count floatBuffer:(const float*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)put:(NSArray<NSNumber*>*)indices count:(int)count intBuffer:(const int*)buffer NS_REFINED_FOR_SWIFT;
|
|
- (int)put:(NSArray<NSNumber*>*)indices count:(int)count shortBuffer:(const short*)buffer NS_REFINED_FOR_SWIFT;
|
|
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|