1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #20731 from komakai:matrix_mult_android_ios

This commit is contained in:
Alexander Alekhin
2021-10-05 15:35:58 +00:00
8 changed files with 90 additions and 2 deletions
+10
View File
@@ -114,7 +114,17 @@ CV_EXPORTS @interface Mat : NSObject
- (BOOL)isSubmatrix;
- (void)locateROI:(Size2i*)wholeSize ofs:(Point2i*)offset NS_SWIFT_NAME(locateROI(wholeSize:offset:));
- (Mat*)mul:(Mat*)mat scale:(double)scale;
/**
Performs element-wise multiplication
@param mat operand with with which to perform element-wise multiplication
*/
- (Mat*)mul:(Mat*)mat;
/**
Performs matrix multiplication
@param mat operand with with which to perform matrix multiplication
@see `Core.gemm(...)`
*/
- (Mat*)matMul:(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:));
+5
View File
@@ -372,6 +372,11 @@ static bool updateIdx(cv::Mat* mat, std::vector<int>& indices, size_t inc) {
return [[Mat alloc] initWithNativeMat:new cv::Mat(_nativePtr->mul(*(cv::Mat*)mat.nativePtr))];
}
- (Mat*)matMul:(Mat*)mat {
cv::Mat temp = self.nativeRef * mat.nativeRef;
return [Mat fromNative:temp];
}
+ (Mat*)ones:(int)rows cols:(int)cols type:(int)type {
return [[Mat alloc] initWithNativeMat:new cv::Mat(cv::Mat::ones(rows, cols, type))];
}
@@ -715,3 +715,9 @@ public extension Mat {
return MatAt(mat: self, indices: indices)
}
}
public extension Mat {
static func *(lhs:Mat, rhs: Mat) -> Mat {
return lhs.matMul(rhs)
}
}