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

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2023-06-01 09:37:38 +03:00
565 changed files with 84396 additions and 17589 deletions
+1 -4
View File
@@ -122,10 +122,7 @@
"}",
"\n"
]
},
"checkHardwareSupport" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"setUseOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"useOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }
}
}
},
"func_arg_fix" : {
@@ -2059,4 +2059,12 @@ public class CoreTest extends OpenCVTestCase {
assertEquals(Core.VERSION, Core.getVersionString());
}
public void testHardwareOptions() {
Core.checkHardwareSupport(0);
boolean original_status = Core.useOptimized();
Core.setUseOptimized(!original_status);
assertEquals(!original_status, Core.useOptimized());
Core.setUseOptimized(original_status);
assertEquals(original_status, Core.useOptimized());
}
}
+39
View File
@@ -14,6 +14,14 @@
#import <Foundation/Foundation.h>
#ifdef AVAILABLE_IMGCODECS
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#elif TARGET_OS_MAC
#import <AppKit/AppKit.h>
#endif
#endif
@class Size2i;
@class Scalar;
@class Range;
@@ -181,6 +189,37 @@ CV_EXPORTS @interface Mat : NSObject
- (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;
#pragma mark - Converters
#ifdef AVAILABLE_IMGCODECS
- (CGImageRef)toCGImage CF_RETURNS_RETAINED;
- (instancetype)initWithCGImage:(CGImageRef)image;
- (instancetype)initWithCGImage:(CGImageRef)image alphaExist:(BOOL)alphaExist;
#if TARGET_OS_IPHONE
- (UIImage*)toUIImage;
- (instancetype)initWithUIImage:(UIImage*)image;
- (instancetype)initWithUIImage:(UIImage*)image alphaExist:(BOOL)alphaExist;
#elif TARGET_OS_MAC
- (NSImage*)toNSImage;
- (instancetype)initWithNSImage:(NSImage*)image;
- (instancetype)initWithNSImage:(NSImage*)image alphaExist:(BOOL)alphaExist;
#endif
#endif
#pragma mark - QuickLook
#ifdef AVAILABLE_IMGCODECS
- (id)debugQuickLookObject;
#endif
@end
+55
View File
@@ -13,6 +13,11 @@
#import "CvType.h"
#import "CVObjcUtil.h"
#ifdef AVAILABLE_IMGCODECS
#import "MatConverters.h"
#import "MatQuickLook.h"
#endif
static int idx2Offset(cv::Mat* mat, std::vector<int>& indices) {
int offset = indices[0];
for (int dim=1; dim < mat->dims; dim++) {
@@ -932,4 +937,54 @@ template<typename T> int putData(NSArray<NSNumber*>* indices, cv::Mat* mat, int
return [self cols];
}
#ifdef AVAILABLE_IMGCODECS
-(CGImageRef)toCGImage {
return [MatConverters convertMatToCGImageRef:self];
}
-(instancetype)initWithCGImage:(CGImageRef)image {
return [MatConverters convertCGImageRefToMat:image];
}
-(instancetype)initWithCGImage:(CGImageRef)image alphaExist:(BOOL)alphaExist {
return [MatConverters convertCGImageRefToMat:image alphaExist:alphaExist];
}
#if TARGET_OS_IPHONE
-(UIImage*)toUIImage {
return [MatConverters converMatToUIImage:self];
}
-(instancetype)initWithUIImage:(UIImage*)image {
return [MatConverters convertUIImageToMat:image];
}
-(instancetype)initWithUIImage:(UIImage*)image alphaExist:(BOOL)alphaExist {
return [MatConverters convertUIImageToMat:image alphaExist:alphaExist];
}
#elif TARGET_OS_MAC
-(NSImage*)toNSImage {
return [MatConverters converMatToNSImage:self];
}
-(instancetype)initWithNSImage:(NSImage*)image {
return [MatConverters convertNSImageToMat:image];
}
-(instancetype)initWithNSImage:(NSImage*)image alphaExist:(BOOL)alphaExist {
return [MatConverters convertNSImageToMat:image alphaExist:alphaExist];
}
#endif
- (id)debugQuickLookObject {
return [MatQuickLook matDebugQuickLookObject:self];
}
#endif
@end
@@ -0,0 +1,35 @@
#ifndef OPENCV_CORE_PYOPENCV_CORE_HPP
#define OPENCV_CORE_PYOPENCV_CORE_HPP
#ifdef HAVE_OPENCV_CORE
static PyObject* pycvMakeType(PyObject* , PyObject* args, PyObject* kw) {
const char *keywords[] = { "depth", "channels", NULL };
int depth, channels;
if (!PyArg_ParseTupleAndKeywords(args, kw, "ii", (char**)keywords, &depth, &channels))
return NULL;
int type = CV_MAKETYPE(depth, channels);
return PyInt_FromLong(type);
}
template <int depth>
static PyObject* pycvMakeTypeCh(PyObject*, PyObject *value) {
int channels = (int)PyLong_AsLong(value);
return PyInt_FromLong(CV_MAKETYPE(depth, channels));
}
#define PYOPENCV_EXTRA_METHODS_CV \
{"CV_MAKETYPE", CV_PY_FN_WITH_KW(pycvMakeType), "CV_MAKETYPE(depth, channels) -> retval"}, \
{"CV_8UC", (PyCFunction)(pycvMakeTypeCh<CV_8U>), METH_O, "CV_8UC(channels) -> retval"}, \
{"CV_8SC", (PyCFunction)(pycvMakeTypeCh<CV_8S>), METH_O, "CV_8SC(channels) -> retval"}, \
{"CV_16UC", (PyCFunction)(pycvMakeTypeCh<CV_16U>), METH_O, "CV_16UC(channels) -> retval"}, \
{"CV_16SC", (PyCFunction)(pycvMakeTypeCh<CV_16S>), METH_O, "CV_16SC(channels) -> retval"}, \
{"CV_32SC", (PyCFunction)(pycvMakeTypeCh<CV_32S>), METH_O, "CV_32SC(channels) -> retval"}, \
{"CV_32FC", (PyCFunction)(pycvMakeTypeCh<CV_32F>), METH_O, "CV_32FC(channels) -> retval"}, \
{"CV_64FC", (PyCFunction)(pycvMakeTypeCh<CV_64F>), METH_O, "CV_64FC(channels) -> retval"}, \
{"CV_16FC", (PyCFunction)(pycvMakeTypeCh<CV_16F>), METH_O, "CV_16FC(channels) -> retval"},
#endif // HAVE_OPENCV_CORE
#endif // OPENCV_CORE_PYOPENCV_CORE_HPP