Download modules/core/misc/objc/common/CVObjcUtil.h from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/core/misc/objc/common/CVObjcUtil.h
- Command line
-
hf download hf://tgollogly/test/modules/core/misc/objc/common/CVObjcUtil.h
-
curl -L -o CVObjcUtil.h https://huggingface.co/tgollogly/test/resolve/main/modules/core/misc/objc/common/CVObjcUtil.h
3.02 kB
| // | |
| // CVObjcUtil.h | |
| // | |
| // Created by Giles Payne on 2020/01/02. | |
| // | |
| 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) { | |
| ret.push_back(converter(obj)); | |
| } | |
| return ret; | |
| } | |
| template <typename CV, typename OBJC> void cv2objc(std::vector<CV>& vector, NSMutableArray<OBJC*>* _Nonnull array, OBJC* _Nonnull (* _Nonnull converter)(CV&)) { | |
| [array removeAllObjects]; | |
| for (size_t index = 0; index < vector.size(); index++) { | |
| [array addObject:converter(vector[index])]; | |
| } | |
| } | |
| template <typename CV, typename OBJC> std::vector<std::vector<CV>> objc2cv2(NSArray<NSArray<OBJC*>*>* _Nonnull array, CV& (* _Nonnull converter)(OBJC* _Nonnull)) { | |
| std::vector<std::vector<CV>> ret; | |
| for (NSArray<OBJC*>* innerArray in array) { | |
| std::vector<CV> innerVector; | |
| for (OBJC* obj in innerArray) { | |
| innerVector.push_back(converter(obj)); | |
| } | |
| ret.push_back(innerVector); | |
| } | |
| return ret; | |
| } | |
| template <typename CV, typename OBJC> void cv2objc2(std::vector<std::vector<CV>>& vector, NSMutableArray<NSMutableArray<OBJC*>*>* _Nonnull array, OBJC* _Nonnull (* _Nonnull converter)(CV&)) { | |
| [array removeAllObjects]; | |
| for (size_t index = 0; index < vector.size(); index++) { | |
| std::vector<CV>& innerVector = vector[index]; | |
| NSMutableArray<OBJC*>* innerArray = [NSMutableArray arrayWithCapacity:innerVector.size()]; | |
| for (size_t index2 = 0; index2 < innerVector.size(); index2++) { | |
| [innerArray addObject:converter(innerVector[index2])]; | |
| } | |
| [array addObject:innerArray]; | |
| } | |
| } | |