Download modules/core/misc/objc/common/MatOfFloat.mm from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/core/misc/objc/common/MatOfFloat.mm
- Command line
-
hf download hf://tgollogly/test/modules/core/misc/objc/common/MatOfFloat.mm
-
curl -L -o MatOfFloat.mm https://huggingface.co/tgollogly/test/resolve/main/modules/core/misc/objc/common/MatOfFloat.mm
1.82 kB
| // | |
| // MatOfFloat.mm | |
| // | |
| // Created by Giles Payne on 2019/12/26. | |
| // | |
| @implementation MatOfFloat | |
| static const int _depth = CV_32F; | |
| static const int _channels = 1; | |
| - (instancetype)initWithNativeMat:(cv::Mat*)nativeMat { | |
| self = [super initWithNativeMat:nativeMat]; | |
| if (self && ![self empty] && [self checkVector:_channels depth:_depth] < 0) { | |
| @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Incompatible Mat" userInfo:nil]; | |
| } | |
| return self; | |
| } | |
| - (instancetype)initWithMat:(Mat*)mat { | |
| self = [super initWithMat:mat rowRange:[Range all]]; | |
| if (self && ![self empty] && [self checkVector:_channels depth:_depth] < 0) { | |
| @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Incompatible Mat" userInfo:nil]; | |
| } | |
| return self; | |
| } | |
| - (instancetype)initWithArray:(NSArray<NSNumber*>*)array { | |
| self = [super init]; | |
| if (self) { | |
| [self fromArray:array]; | |
| } | |
| return self; | |
| } | |
| - (void)alloc:(int)elemNumber { | |
| if (elemNumber>0) { | |
| [super create:elemNumber cols:1 type:[CvType makeType:_depth channels:_channels]]; | |
| } | |
| } | |
| - (void)fromArray:(NSArray<NSNumber*>*)array { | |
| [self alloc:(int)array.count / _channels]; | |
| [self put:0 col:0 data:array]; | |
| } | |
| - (NSArray<NSNumber*>*)toArray { | |
| int length = [self length]; | |
| NSMutableArray<NSNumber*>* data = createArrayWithSize(length, @0.0); | |
| [self get:0 col:0 data:data]; | |
| return data; | |
| } | |
| - (int)length { | |
| int num = [self checkVector:_channels depth:_depth]; | |
| if (num < 0) { | |
| @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Incompatible Mat" userInfo:nil]; | |
| } | |
| return num * _channels; | |
| } | |
| @end | |